Interview Questions

How to loop a sequence of TestSteps X times

SoapUI FAQ


(Continued from previous question...)

How to loop a sequence of TestSteps X times

A simple loop is easiest achieved by placing a Groovy Script TestStep after the last TestStep in the loop with the following content:

1.if( context.loopIndex == null )
2. context.loopIndex = 0
3.
4.if( ++context.loopIndex < 10 )
5. testRunner.gotoStepByName( "Name of first TestStep in loop" )

This script first creates the loop counter in the context and then loops back until the value is 10 (think of it as a do...while loop)

(Continued on next question...)

Other Interview Questions