Ask a Question

conditional goto based on pass/failed status of a teststep

Philippe_Lebacq
Contributor

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 4
Unhandled
Contributor

Re: conditional goto based on pass/failed status of a testst

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
Occasional Contributor

Re: conditional goto based on pass/failed status of a testst

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
Super Contributor

Re: conditional goto based on pass/failed status of a testst

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.

Nilesh
Occasional Contributor

Re: conditional goto based on pass/failed status of a testst

Thanks Radford

It worked and able to get the status,

And Yes, I was running only groovy script instead of whole testcase hence it was showing me above error.

Thanks Again.

cancel
Showing results for 
Search instead for 
Did you mean: