I'm pretty new to Groovy and SoapUI test suite, and I'm getting an error when I try to execute a Conditional Goto. The thing is, I have a couple of REST services which answer a JSON string, and I want to create a TestSuite in which service B gets executed only if service A returns an specific code on its answer. So, to make things more clear:
Service A returns something like
{
"parentObject": {
"myCode": "0",
"severity": "INFO"
},
"message": "operation successfull"
}
If code equals to "1" I should run service B, otherwise not. My Conditional Goto is:
contains(text(), "1")
also tried with contains(., "1")
If I test this condition from the run icon in the Conditional Goto window, it solves correctly the condition, but if I run it from the TestSuite, I get the message "Missing matching condition, moving on" and executes the service B.
There are only a few search results in Google associated to this error, and only in one of them I've found another option (link here) with a Groovy script:
import groovy.json.JsonSlurper
responseContent = testRunner.testCase.getTestStepByName("Service A step").getPropertyValue("response")
slurperresponse = new JsonSlurper().parseText(responseContent)
myCode = slurperresponse.parentObject.myCode
if ('1'.equalsIgnoreCase(myCode.toString())) testRunner.gotoStepByName("Service B Step")
else log.info("Some error")
but it didn't work, meaning that again the service B gets executed, event when it shouldn't).
I would really appreciate if you could give a hand here, with any of both options, if you know why the Conditional Goto is showing that error or why the Service B gets executed with the Groovy Script.
Thanks in advance
UPDATE: the list of steps in the TestSuite, according to @Rao request (sorry, I can't add an image with the real components)
- REST service, returning JSON response
- Groovy Script, to read a token contained in the previous response and insert it as a header in the next REST service
- REST service (this would be "Service A"), returning JSON response (it receives correctly the header inserted in previous step)
- Groovy Script (shown in description)
- REST service (this would be "Service B"), returning JSON response
This are my only components in the TestSuite