cancel
Showing results for 
Search instead for 
Did you mean: 

Stop test from groovy

itaykaldi
Contributor

Stop test from groovy

Hey,
I try to use testRunner.cancel( "Stop Test" )

But if I will add another line after like log.info "bla bla"
It will execute it..

How can I stop the test from groovy without continuing other lines of script?
4 REPLIES 4

Re: Stop test from groovy

Hi,

The testRunner.cancel() with stop the execution for the run. So if you have,

SoapRequest or RestRequest
Groovy Script1
Groovy Script2

and in Groovy Script1 test step you have testRunner.cancel() it will execute Groovy Script1 but not Groovy Script2. If within the groovy script you want to run it conditionally you have to use if-else clause.

Also you can control the flow of the testCase you can do that as well,
http://www.soapui.org/Functional-Testin ... -flow.html

Thanks,
Jeshtha


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

Re: Stop test from groovy

Try this.

log.info "...first line.........."
testRunner.cancel( "Stop the testRunner" )
return
log.info "...second line.........."

Re: Stop test from groovy

Hi,

Return works to stop the execution for current step. Thanks a lot for sharing this.

Thanks,
Jeshtha


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

Re: Stop test from groovy

Another way I found was to have an end step, say called "End". In there I just have a log message saying something like :

log.info "test complete"

 

In the conditional I can then simply do the following:

 

testRunner.gotoStepByName("End")

 

Any of the interim test steps are skipped over. Just another way of cracking the nut.

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors