Forum Discussion
6 Replies
- sanjSuper Contributor
I will see if I can a find a groovy example
This may be doable using groovy not sure yet
- SandyapitesterFrequent Contributor
Hi San,
If u share the script it would be more helpful for me
- nmraoChampion Level 3The best practise is to have test cases independent of each other.
- SandyapitesterFrequent Contributor
Hi,
All test cases are depended based on the teststep status code need to run another test cases if any test cases are failed there is no point to add the another testcases.
that's the reason am looking for this solution.
- Bill_In_IrvineContributor
I think using Groovy is the likely way to the solution.
I don't have a need to call a request based on the response of a previous request however I can only give some
guide on how I go about it and you can finish the details (because working with Groovy is fun!).The basics of running test cases via Groovy are covered here:
https://support.smartbear.com/readyapi/docs/testing/scripts/samples/cross-project.html
I suppose you can fullfill your goal in a Setup script at the Project level, test suite level or test case level.
I'd go about it by first setting up my test steps, and then get to work with Groovy.You can call a test step based on the information in the above URL. Once you executed that step, you can
get the response. Here is how I get the response, but note I did this in a Groovy Test Step within a test case:import groovy.json.JsonSlurper def previousTestStep = testRunner.getTestCase().getTestStepByName("request1") String propertySpec = '${' + previousTestStep.name + '#Response}' def response = context.expand(propertySpec) def jsonSlurper = new JsonSlurper().parseText(response) // Now suppose your server's response has a name field called status which has a value "Success" or "Fail" def status = jsonSlurper.status if( jsonSlurper.status == "Success") { // call request2 } else { // call request3 }
You can stop the IDE from executing the steps again with testRunner.cancel()
testRunner.cancel("done")
'again, I have not called other requests based on responses as so far I had no need but I hope this helps to give you a guide.
Related Content
- 2 years agoKimdongart1
- 5 years agoskaushik9
Recent Discussions
- 11 hours agoKay