Arah
4 years agoOccasional Contributor
Running 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);