Contributions
Re: Assert if any TestStep failed
In TestCase (A) in Groovy Script TestStep I run another TestCase (B), after that TestCase (C) and so on... In same Groovy Script TestStep that runs another TestCases I want an assertion that causes TestCase(A) failed if any of the TestSteps in TestCases (B,C, ...) failed. The code I pasted does not work for Groovy Script TestSteps in TestCases (B, C, ...) even if there is an assertion inside of them. TestCase (A) just ignores it and run another TestSteps which I want to avoid.841Views0likes2CommentsAssert if any TestStep failed
Hey, how can I assert if any of the TestSteps failed using Groovy Script? I have written a groovy script script that among other things run another TestCase and I want it to assert every TestStep (in called TestCase) if it failed. Currently it check TestSteps but it does not include Groovy Script Steps (Groovy Script steps that have asserts inside of them). This is what I have so far... //Get TestStepList from called Project def assertFinishedStatus = testRunner.testCase.testSuite.project.workspace.getProjectByName(projectName).getTestSuiteByName(testSuitetName).getTestCaseByName(testCaseName).getTestStepList() //Assert if any step with assertions failed in called TestCase def moduleStatus = true; assertFinishedStatus.each{ // check that testStep has assertionStatus // (for example groovy testSteps hasn't this property since // there is no asserts on its) if(it.metaClass.hasProperty(it,'assertionStatus')){ if(it.assertionStatus == AssertionStatus.FAILED){ log.info "TestStep: ${it.name} - - - - - - - - - - - - Status: FAILED" return moduleStatus = false; }else if(it.assertionStatus == AssertionStatus.VALID || it.assertionStatus == AssertionStatus.UNKNOWN){ log.info "TestStep: ${it.name} - - - - - - - - - - - - Status: OK!" return moduleStatus = true; } } } assert(moduleStatus != false)901Views0likes4CommentsRe: Running Another TestCases, looping through Properties (getValues &SetValues) - Groovy Script
Hey, about the independency of every TestCase, at work we use that kind of thing, so i was trying to recreate it (I do not have access to script that does this and all other things) this is what I wanted to achieve //Get all properties from current TestCase's TestStep "LIST" and transfer them to indicated TestCase in code above, and set them in TestStep "LIST" def ListProperties = testRunner.testCase.getTestStepByName("LIST").getPropertyList() ListProperties.each{ lp-> passPropertiesToList = testRunner.testCase.testSuite.project.workspace.getProjectByName(projectName).getTestSuiteByName(testSuitetName).getTestCaseByName(testCaseName).getTestStepByName("LIST").setPropertyValue("${lp.getName()}", "${lp.getValue()}"); } //Get all properties from current TestCase and transfer them to indicated TestCase in code above def exitProperties = testRunner.testCase.testSuite.project.workspace.getProjectByName(projectName).getTestSuiteByName(testSuitetName).getTestCaseByName(testCaseName).getTestStepByName("EXIT").getPropertyList() exitProperties.each{ ep-> passPropertiesToExit = testRunner.testCase.testSteps["EXIT"].setPropertyValue("${ep.getName()}", "${ep.getValue()}"); } Is there other way to run differentTestCase, than using .workspace?677Views0likes0CommentsRunning Another TestCases, looping through Properties (getValues &SetValues) - Groovy Script
Hello, how can I get all of the properties (it shouldn’t matter if there are only 2 or 100 on the list) with values from TestStep “LIST” from TestCase S_TC_Addition and set them on the TestStep “LIST” in TestCase M_TC_Add, and then, get all properties and values from TestStep “EXIT” in TestCase M_TC_Add and set them on the TestStep “EXIT” in TestCase S_TC_Addition, in groovy script (in this case EXECUTION_Addition)? At the moment I have this (which only gets and sets properties that I've manually indicated "FirstValue", "SecondValue"): import com.eviware.soapui.impl.wsdl.* import com.eviware.soapui.impl.wsdl.testcase.* import com.eviware.soapui.model.testsuite.* //Locating TestCase in different project def projectName = testRunner.testCase.getTestStepByName("TRACING_TC_Addition").getPropertyValue("PROJECT_NAME") def testSuitetName = testRunner.testCase.getTestStepByName("TRACING_TC_Addition").getPropertyValue("TEST_SUITE_NAME") def testCaseName = testRunner.testCase.getTestStepByName("TRACING_TC_Addition").getPropertyValue("TEST_CASE_NAME") //Getting only two properties from the "LIST" TestStep in S_TC_Addition TestCase def firstNumber = testRunner.testCase.getTestStepByName("LIST").getPropertyValue("FirstValue") def secondNumber = testRunner.testCase.getTestStepByName("LIST").getPropertyValue("SecondValue"); //Setting only two properties on the "LIST" TestStep in M_TC_Add TestCase def passFirst = testRunner.testCase.testSuite.project.workspace.getProjectByName(projectName).getTestSuiteByName(testSuitetName).getTestCaseByName(testCaseName).getTestStepByName("LIST").setPropertyValue("FirstValue", firstNumber); def passSecond = testRunner.testCase.testSuite.project.workspace.getProjectByName(projectName).getTestSuiteByName(testSuitetName).getTestCaseByName(testCaseName).getTestStepByName("LIST").setPropertyValue("SecondValue", secondNumber); //Running TestCase in different project testCaseToRun = testRunner.testCase.testSuite.project.workspace.getProjectByName(projectName).testSuites[testSuitetName].testCases[testCaseName] testCaseToRun.run(null,false) //Getting one property from the "EXIT" TestStep in M_TC_Add TestCase def getAdditionResult = testRunner.testCase.testSuite.project.workspace.getProjectByName(projectName).getTestSuiteByName(testSuitetName).getTestCaseByName(testCaseName).getTestStepByName("EXIT").getPropertyValue("additionResult"); //Setting only one property on the "EXIT" TestStep in S_TC_Addition TestCase testRunner.testCase.testSteps["EXIT"].setPropertyValue( "additionResult", getAdditionResult);773Views0likes2Comments