Forum Discussion

bpistole's avatar
7 years ago

skip test step using groovy

I have a test where I need to iterate through the response to validate several values.

If the values match I want to goto a "pass" test step but if they fail I want to go to a different "fail" test step.

if (responseCategory != expectedCategory){"Test Failed")
   testRunner.gotoStepByName("Test Case  - FAIL")
else{"Test Passed")
   testRunner.gotoStepByName("Test Case  - PASS")


The "Test Case - "FAIL" is followed by this script:"Result not as expected!")

This is used to abort the test on a fail condition.

After the there is the "Test Case - "PASS" test step followed by the dataSource loop.


However, the test allows follows the fail path regardless of the if/else result.  I can watch the logs and they will log the "Test Passed" yet the "Test Case - "FAIL" test step will run instead of the "Test Case - "PASS" test step.


What am I missing here?  My understanding was that the gotoStepByName was programmatically the same as the condition goto test step.  I've used the condition goto test step on other test cases and it worked in this same set up.




3 Replies

  • Nastya_Khovrina's avatar
    SmartBear Alumni (Retired)

    Hi Billy,


    I see that you opened a case regarding this issue. It would be great if you can share your project (or a sample project) with us in the case, so we can better understand and test your scenario. Thanks.

  • I ended up getting this working but to be honest, I'm not sure what I did. :)


    if (expectedFeature != responseFeature)
    {" " + responseFeature + " != " + expectedFeature)" Fail")
    testRunner.gotoStepByName("TC FAIL")
    {" " + responseFeature + " == " + expectedFeature)" Pass")
    testRunner.gotoStepByName("TC PASS")