Ask a Question

skip test step using groovy

bpistole
Contributor

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){
   log.info("Test Failed")
   testRunner.gotoStepByName("Test Case  - FAIL")
}
else{
   log.info("Test Passed")
   testRunner.gotoStepByName("Test Case  - PASS")
}

 

The "Test Case - "FAIL" is followed by this script:

testRunner.fail("Result not as expected!")

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

After the testRunner.fail 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.

 

Thanks,

Billy

3 REPLIES 3
Nastya_Khovrina
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.


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
bpistole
Contributor

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

 

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

}

 

 

Nastya_Khovrina
SmartBear Alumni (Retired)

Billy,

 

Glad to hear that it's working now!


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: