Forum Discussion

v3t3a's avatar
v3t3a
Occasional Contributor
10 years ago
Solved

GotoTestStep to another test case

Hello!

I'm searching since Yesterday but i found nothing for my problem:
- I have :
-> One test suite : "testSuite"
-> Two test case : "testCase_1" and "testCase_2"
-> Multiple testStep :
"testCase_1" : "testStep_1" ; "testStep_2" ;"testStep_3"
"testCase_2" : "testStep_1" ; "testStep_2" ;"testStep_3"

- What i want to do :
-> With a groovy script, which will be in "testCase_2", test the result (OK or NOT RUN) of "testCase_1" -> "testStep_2"
-> If "testCase_1" -> "testStep_2" = OK
-> goto "testCase_2" -> "testStep_3"

-> If "testCase_1" -> "testStep_2" = NOT RUN
-> goto "testCase_1" -> "testStep_1"


- What i tried (i'm in testCase_2) :

testRunner.testCase.testSuite.project.name
import com.eviware.soapui.model.testsuite.TestStepResult.TestStepStatus
import com.eviware.soapui.impl.wsdl.WsdlTestSuite
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep




myTestStepResult = testRunner.testCase.testSuite.getTestCaseByName("testCase_1").getTestStepByName("testStep_2").run(testRunner, context)
myStatus = myTestStepResult.getStatus()
if (myStatus == TestStepStatus.OK)
testRunner.gotoStepByName("testStep_3")
else{
testRunner.testCase.testSuite.getTestCaseByName("testCase_1").getTestStepByName("testStep_1").gotoStepByName("testStep_1");
}



But i have this error :

groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.ManualTestStep.gotoStepByName() is applicable for argument types: (java.lang.String) values: [testStep_1] error at line: 14

I hope someone can help me...
Thanks in advance!

v3t3a
  • Hello,
    you can use following in "else" block:

    def tCase = testRunner.testCase.testSuite.testCases["Name of test cases"]

    def tStep = tCase .testSteps["test step you want to run"]

    tStep.run(testRunner, context)

    Also,
    if (myStatus == TestStepStatus.OK) to be replaced with following:

    if (myStatus == "OK")

    Hope it helps,
    Reshma S

3 Replies

  • Hello,
    you can use following in "else" block:

    def tCase = testRunner.testCase.testSuite.testCases["Name of test cases"]

    def tStep = tCase .testSteps["test step you want to run"]

    tStep.run(testRunner, context)

    Also,
    if (myStatus == TestStepStatus.OK) to be replaced with following:

    if (myStatus == "OK")

    Hope it helps,
    Reshma S
  • v3t3a's avatar
    v3t3a
    Occasional Contributor
    Thanks ReshmaSachdev,

    I'll try it soon.

    Sorry for late response.
  • v3t3a's avatar
    v3t3a
    Occasional Contributor
    It works fine!
    Big thanks ReshmaSachdev.


    On the other hand, this version [if (myStatus == "OK")] instead of [if (myStatus == TestStepStatus.OK)] doesn't work for me... It's not a problem because i left my original version