Repeat a Test Step until you get desired response and then move to next step.
Hi,
I have a requirement where I am querying using a GET Request or say a DB select.
This is async service which returns me a state say "in-progress" . Then I added a step called delay with 2 seconds delay and checking the status again as it should be "success" or "fail". However this is not good approach and fails sometimes on different servers.
I am looking for some solution how I can do this?
I tried few stuff with Groovy and Data Source Loops but still don't know which is the best approach. Also, for how long shall I loop. It might happen that there is some deadlock on DB Level and this might loop for ever. Shall I have some limit also say 5 seconds or something.
I have attached structure of my project. I need to re-run the step called "Verify Payment Status in DB" until status is success and then move to other steps.
Any help will be much appreciated.
Thanks,
Vivek
def response = context.expand( '${TestStep_101#Response}') def holder = new com.eviware.soapui.support.XmlHolder(response) if (holder) { def isRetry = true while(isRetry) { def state = holder.getNodeValue('//*:payments/*:payment-state') log.info "value of state in the response is ${state}" if (state == 'success') { log.info "Since the value is success, setting value of isRetry to false" isRetry = false } else { log.info "Retring as state is not success" testRunner.runTestStepByName('TestStep_101') } } }
Please check if the above script helps.