Reputation: 29
I currently have a test step which calls another test case. In the called test case, I have a groovy script with a conditional if statement. If a certain condition is met I want to cancel the current execution. I've added the below two lines;
testRunner.cancel("Condition not met"); return
What I find however, is that control is passed back to the test case in which the call was made from, and it continues to execute the remaining test steps within the case. The only way around this is to use testRunner.fail(""), but this is not really what I want.
Please can anyone advise. Many thanks.
Upvotes: 0
Views: 1615
Reputation: 29
Thanks, these are both great options, however I am calling the test case via the 'Run Test Case' option. I need to do it this way (rather than using a groovy script) to keep it thread safe as I need to select the option 'Run Primary TestCase (wait for running to finish, Thread-Safe').
Upvotes: 0
Reputation: 873
Assuming you are doing your script run() on the testcase, you may catch the result of that testcase, and then choose how to act.
def result = testRunner.testCase.testSuite.getTestCaseByName("The Name Of Your Testcase").run(null, false);
def status = result.getStatus()
if (status == com.eviware.soapui.model.testsuite.TestRunner.Status.CANCELED) {
testRunner.cancel("Condition not met");
return;
}
Upvotes: 1
Reputation: 3936
Instead of writing testRunner.cancel in the called step. You can return 0/1 from the called groovy step
return 0
Based on the value received in calling function 0 or 1 , you can do
testRunner.cancel("Cancelling the test run further steps as there is a failure")
return
Upvotes: 1