Forum Discussion
Hi.
I run a test in a loop with help of Groovy script.
Here is simple script
if( context.loopIndex == null ) context.loopIndex = 0 if( ++context.loopIndex < 10 ) testRunner.gotoStepByName( "Name of first TestStep in loop" )
Testcase has to steps:
1. SOAP request
2. Groovy script which loop step 1
I have two assertions
1. Contains text - Error 20. If text IS presented than it s VAILD
2. Xpath - if the value of the nod presented than it s VAILD
During making request sometimes service give me another wrong response, which I don't need to catch. When I receive "Error 20" I want to ignore that response and continue looping my request until I catch assertion number 2.
Problem is, that when service returns "Error 20", assertion 2 fails. because server return completely wrong response. That's why I wanted to create conditions like that test case stopped only if both assertions failed, not only one of them.
OR
If you can recommend how to create conditions with one assertion, but which will have something like "If I see Error 20 response, ignore it and continue loop until assertion 2 failed"
- Radford8 years agoSuper Contributor
While you could use Groovy I personally always like to see if the base functionality can solve the problem. Have you looked at the Assertion TestStep in particular Groups they allow you to set up AND/OR groups. From the docs about the OR condition:
"At least one assertion within the group must evaluate to VALID to assert a group PASSED condition."
Thus you can put an assertion test step after your SOAP step and then move your assertions from the soap step into the assertion test step.
But looking at your last line:
"and continue loop until assertion 2 failed"
If you really want to remember a fail condition from a previous run through the loop and combine it with a check from the current run through the loop, then yes you'll probably need Groovy. Very briefly, you'd want to remove your assertions from the SOAP test step, then within your Groovy script get and check you data (you can use the point and click functionality to get the data) and then look at saving relevant information to the context for retrieving and checking later on. You can then use the fail method of the testRunner object that the Groovy script provides.
- Postavshik8 years agoNew Contributor
Hi.
Thank you for your detailed reply, but unfortunately your solutions only for SoapUI Pro version. I have the free one.
Do you know how exactly to do that just with groovy script?
- Radford8 years agoSuper Contributor
OK... This is the "Pro" forum, the open source forum can be found here:
https://community.smartbear.com/t5/SoapUI-Open-Source/bd-p/SoapUI_OS
Sorry I can't give you the exact details as that depends of your exact scenarios, also I am not exactly sure what features are available in the open source version.
You might be able to get a better answer from the people in the SoapUI Open Source as they will know its capabilities better.
[nmrao can you move this post to the SoapUI Open Source forum?]
Related Content
- 8 years ago
- 6 years ago
- 6 years ago
- 8 years ago
Recent Discussions
- 3 days ago