Forum Discussion

cbyndr's avatar
cbyndr
Contributor
14 years ago

cancel test suite from groovy script

How may this be done?

And if it can be done from a script step, could it also be done from a script assertion?

8 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hello,

    from groovy test step:

    def tsr = context.getProperty( "#TestSuiteRunner#" )
    if( tsr != null ) tsr.cancel( "The assertion failed" )


    but in script assertion try:

    context.testRunner.cancel()


    Let me know does this helps,
    robert
  • Thank you. This helps, but we're not quite there.

    Adding this code to the groovy script step seems to stop the test suite, whether or not the assertion in the preceding test step fails.

    How can I make the test suite stop if the assertion in the test step fails? Could I put the assertion in the script itself? By doing that I have only been able to stop the test case, not the test suite.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    hi,

    so here is my suggestion:

    import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus

    def tsr = context.getProperty( "#TestSuiteRunner#" )
    if( tsr != null ){
    if( tsr.currentTestCase.getTestStepByName("My Request").assertionStatus==AssertionStatus.FAILED ){
    tsr.cancel( "The assertion failed" )
    }
    }


    also you need to uncheck 'Fail on error' option in Test Case options

    Let us know if this helps

    regards
    nebojsa
    eviware.com
  • one more question, will this also work if running from the command line using testrunner?
    • saprao's avatar
      saprao
      Occasional Contributor

      Hi ,

       

      I have same query , i have to stop the entire testsuite through groovy when soap response assertion is fail. I am able to stop the execution in test case level by using testrunner.cancel().

       

      I have seen this blog in smart bear for this query

       

      import com.eviware.soapui.model.testsuite.Assertable.AssertionStatus

      def tsr = context.getProperty( "#TestSuiteRunner#" )
      if( tsr != null ){
      if( tsr.currentTestCase.getTestStepByName("My Request").assertionStatus==AssertionStatus.FAILED ){
      tsr.cancel( "The assertion failed" )
      }
      }

       can i know that what value need to pass to "#TestSuiteRunner# property.. .

       

      Thanks

      • saprao's avatar
        saprao
        Occasional Contributor

        Hi ,

         

        Can anyone help me, how to stop the test suite execution through Groovy when any assertion is fail in run time.

        I have seen above blog in the internet but it wouldn't worked out.

        context.getProperty( "#TestSuiteRunner#" )

        In above statement, what value i need to pass.

         

        Thanks