Scripting goto next step
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Scripting goto next step
I am using SoapUI 5.7. In my test steps, I use a groovy script to conditionally jump past a step as it will fail if running the suite locally. I can skip to another step by name, but I am concerned if someone were to rename a step or rearrange them it would break things. As such, how can I just check what step index I am currently on and jump past the next step (current +2)?
testrunner.gotoStepByName()
testrunner.gotoStep()
//--unable to get the index from the step class
context.getCurrentStep()
- Labels:
-
Scripting
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
try to run your teststep using groovy rather than by sequence.
disable you tests in the soapui and control the test step execution based on criteria by using the below
testRunner.runTestStepByName("testStepName")
lets say you have three steps --> testStepName1, testStepName2 & testStepName3
testRunner.runTestStepByName("testStepName1")
if(<someCondition>) then
testRunner.runTestStepByName("testStepName3")
else
testRunner.runTestStepByName("testStepName2")
testRunner.runTestStepByName("testStepName3")
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using a Groovy script to check for a condition (if local) and skipping the next step if it is true. I am currently skipping it by name but I would prefer just to use the (calculated) step index in case the step name changes or the other non-skipped steps change order. In general, I want to avoid referencing steps by name in case of name changes.
Is there a way I can calculate the index of the step I am currently on to skip over the next step? Something like the following?
if(condition){
stepNum = context.getCurrentStep().index //--unsure how to do this
stepNum = stepNum+2
testRunner.gotoStep(stepNum)
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @tabbykat
You are still in the same predicament if you are using an index to the step you want to skip to... There is same possibility of people renaming a test case as there is people re-arranging the test step sequence. You might have to reconsider to a more robust process to determine which test step to jump to. Maybe have two testcases... one for local and one for not. Maybe add some documentation to the beginning of the test case to tell other people to don't touch or something.
Regards,
Todd
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your feedback. However, are you aware of a solution for the following?
Is there a way I can calculate the index of the step I am currently on to skip over the next step? Something like the following?
if(condition){
stepNum = context.getCurrentStep().index //--unsure how to do this
stepNum = stepNum+2
testRunner.gotoStep(stepNum)
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @tabbykat
The following link should give you enough information to do what you need... A similar question has been asked before...
Regards,
Todd
