Forum Discussion

jkrier's avatar
jkrier
Regular Contributor
10 years ago

[RES]Groovy step is treated differently when ran from suite

I am trying to loop a set of test steps for a specific amount of runs in the middle of a test suite. I have written a Groovy script to do this. If I disable the Groovy loop script and then run my suite up to the Groovy loop step and then manually run the Groovy step from inside of the Groovy step it works; the previous steps run the exact amount of times I wish them to. When the Groovy script is enabled and I run from the suite the suite will loop the steps in the Groovy script infinitely.

Is there a reason that this happens?


Here is my Groovy script.

def loop = 1
log.info loop
while (loop < 2){ //must match if loop
log.info "Still Running " + loop
//You have to explicitly list all steps to run between the loop script and the test step loop start
testRunner.runTestStepByName("getUniqueExternalReferenceValues 2")
sleep 1000
testRunner.runTestStepByName("getTransitionPackages")
sleep 1000
testRunner.runTestStepByName("TransitionProps")
sleep 1000
testRunner.runTestStepByName("UpdateService_TransitionServiceItem")
sleep 1000
testRunner.runTestStepByName("getSoaTransactionsByExternalAccountReference 3")
sleep 1000
testRunner.runTestStepByName("checkTransitionStatus")
sleep 1000
testRunner.runTestStepByName("TransitionVariables")
sleep 10000
loop = loop + 1
}

if (loop == 2){ //must match while loop
testRunner.gotoStepByName("getUniqueExternalReferenceValues 3")
loop = 0
log.info "ALL DONE "+loop
}


I know that you do not support custom scripts but what I think is incorrect is that it's treated differently depending on how it's ran plus technically I believe my script should work. It is correct code to do what I want and the soapUI client is ignoring what the script is telling it to do. If I run this script in a Groovy console and remove the test steps the loop works just fine. For example, if you comment out all of the soapUI test steps and run the script in a Groovy console the output is as expected.

def loop = 1
println loop
while (loop < 5){ //must match if loop
println "Still Running " + loop
//You have to explicitly list all steps to run between the loop script and the test step loop start
/*testRunner.runTestStepByName("getUniqueExternalReferenceValues 2")
sleep 1000
testRunner.runTestStepByName("getTransitionPackages")
sleep 1000
testRunner.runTestStepByName("TransitionProps")
sleep 1000
testRunner.runTestStepByName("UpdateService_TransitionServiceItem")
sleep 1000
testRunner.runTestStepByName("getSoaTransactionsByExternalAccountReference 3")
sleep 1000
testRunner.runTestStepByName("checkTransitionStatus")
sleep 1000
testRunner.runTestStepByName("TransitionVariables")
sleep 10000*/
loop = loop + 1
}

if (loop == 5){ //must match while loop
//testRunner.gotoStepByName("getUniqueExternalReferenceValues 3")
loop = 0
println "ALL DONE "+loop
}

groovy> def loop = 1
groovy> println loop
groovy> while (loop < 5){ //must match if loop
groovy> println "Still Running " + loop
groovy> //You have to explicitly list all steps to run between the loop script and the test step loop start
groovy> /*testRunner.runTestStepByName("getUniqueExternalReferenceValues 2")
groovy> sleep 1000
groovy> testRunner.runTestStepByName("getTransitionPackages")
groovy> sleep 1000
groovy> testRunner.runTestStepByName("TransitionProps")
groovy> sleep 1000
groovy> testRunner.runTestStepByName("UpdateService_TransitionServiceItem")
groovy> sleep 1000
groovy> testRunner.runTestStepByName("getSoaTransactionsByExternalAccountReference 3")
groovy> sleep 1000
groovy> testRunner.runTestStepByName("checkTransitionStatus")
groovy> sleep 1000
groovy> testRunner.runTestStepByName("TransitionVariables")
groovy> sleep 10000*/
groovy> loop = loop + 1
groovy> }
groovy> if (loop == 5){ //must match while loop
groovy> //testRunner.gotoStepByName("getUniqueExternalReferenceValues 3")
groovy> loop = 0
groovy> println "ALL DONE "+loop
groovy> }

1
Still Running 1
Still Running 2
Still Running 3
Still Running 4
ALL DONE 0

14 Replies