Forum Discussion

Philippe_Lebacq's avatar
Philippe_Lebacq
Contributor
14 years ago

conditional goto based on pass/failed status of a teststep

Neither property transfer or conditional goto does not allow to select a teststep execution status in the list of properties. I can select the response of a request and then do some xpath checks on the response content, but I can't find a way to simply verify a pass/failed status of an individual teststep.
Same would be handy too on testcase/testsuite execution status.
Kinds, Philippe.

4 Replies

  • I am unaware of a way to do this using the native soapUI interface. However, you could get the same functionality with a Groovy Test Step.

    Insert a Groovy Test Step after the test step of which you want to check status.

    In the Groovy Test Step, insert something like the following. This script will transfer execution of a test case to an arbitrary test step if the previous test step failed.


    def lastResult = testRunner.getResults().last()
    def lastResultName = lastResult.getTestStep().getLabel().toString()
    def lastResultStatus = lastResult.getStatus().toString()

    log.info 'Test Step [' + lastResultName + '] status: ' + lastResultStatus

    if( lastResultStatus == 'FAILED' )
    {
    myGotoStepName = 'Other TestStep Name'
    log.info 'Goto step [' + myGotoStepName + ']'
    testRunner.gotoStepByName( myGotoStepName )
    }
    else
    {
    log.info 'Continue to next step'
    }
    • Nilesh's avatar
      Nilesh
      Occasional Contributor

      Hi Unhandled,

       

      I am bit new to SOAP UI,

      I have added rest reequest before the groovy script and manually run it and then added groovy script step and 

      I copied the same code and when try to run it,It shows error

      "java.util.NoSuchElementException: Cannot access last() element from an empty list"

       

      Can you suggest what changes or steps to follow to get the Exact status of the teststep.

       

      Thanks

      • Radford's avatar
        Radford
        Super Contributor

        Are you running the complete test case, allowing the two test steps to be run sequentially? Or are you manually running the REST request test step, and then running the Groovy test step?

         

        I believe that the provided testRunner variable is for the context of the run, thus you have to run the test case to get the results of previous test steps.

         

        "java.util.NoSuchElementException: Cannot access last() element from an empty list" is saying there are no results in the testRunner object.