Forum Discussion

itaykaldi's avatar
itaykaldi
Contributor
10 years ago

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

  • Try this.

    log.info "...first line.........."
    testRunner.cancel( "Stop the testRunner" )
    return
    log.info "...second line.........."
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    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
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

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

    Thanks,
    Jeshtha
    • inthegarage's avatar
      inthegarage
      Occasional Contributor

      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.