Continue Assertions in Groovy Step when one assertion fails
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2011
08:08 PM
11-03-2011
08:08 PM
Continue Assertions in Groovy Step when one assertion fails
We are using SoapUI Pro with Test Cases where we write assertions inside Groovy Steps.
Test Step: Groovy Script Step
//Assertion 1
def ProductOfferingCode = context.expand(...something...)
assert ProductOfferingCode == 'something'
//Assertion 2
def productOfferingSource = context.expand(...something...)
assert productOfferingSource == 'something'
//Assertion 3
def isSubscription = context.expand(...something...)
assert isSubscription == 'something'
When Assertion 1 fails, SoapUI Pro will "Exit" the Groovy Step, and go to next step in Test Case.
How can I force SoapUI to continue with Assertion 2 and Assertion 3, even when Assertion 1 fails.
Also, I already know about the "Abort on Error" option, which continues to the next step when one step fails. But what I need is to continue with other assertions in the same Groovy step.
Regards,
Jatin Kumar
Test Step: Groovy Script Step
//Assertion 1
def ProductOfferingCode = context.expand(...something...)
assert ProductOfferingCode == 'something'
//Assertion 2
def productOfferingSource = context.expand(...something...)
assert productOfferingSource == 'something'
//Assertion 3
def isSubscription = context.expand(...something...)
assert isSubscription == 'something'
When Assertion 1 fails, SoapUI Pro will "Exit" the Groovy Step, and go to next step in Test Case.
How can I force SoapUI to continue with Assertion 2 and Assertion 3, even when Assertion 1 fails.
Also, I already know about the "Abort on Error" option, which continues to the next step when one step fails. But what I need is to continue with other assertions in the same Groovy step.
Regards,
Jatin Kumar
4 REPLIES 4
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2011
06:20 AM
11-08-2011
06:20 AM
HI,
in groovy
assert ProductOfferingCode == 'something' throws AssertionException so the flow of the script ends there.
Here is the simple tweak
So you can add which assertions failed and if there is something in assertionList it means that somethig failed.
Hope this helps
regards
nebojsa
SmartBEar Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
in groovy
assert ProductOfferingCode == 'something' throws AssertionException so the flow of the script ends there.
Here is the simple tweak
def assertionList = []
//Assertion 1
def ProductOfferingCode = context.expand(...something...)
ProductOfferingCode == 'something' ? log.info "Assertion1 pass" : assertionList.add("Assertion1 fails")
//Assertion 2
def productOfferingSource = context.expand(...something...)
productOfferingSource == 'something' ? log.info "Assertion2 pass" : assertionList.add("Assertion2 fails")
//Assertion 3
def isSubscription = context.expand(...something...)
isSubscription == 'something' ? log.info "Assertion3 pass" : assertionList.add("Assertion3 fails")
assert assertionList.isEmpty() : assertionList.toString()
So you can add which assertions failed and if there is something in assertionList it means that somethig failed.
Hope this helps
regards
nebojsa
SmartBEar Software
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2016
12:35 AM
08-16-2016
12:35 AM
It is not working for me , Got compilation error
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2016
04:32 AM
08-16-2016
04:32 AM
Hoping that you may find the below thread & its comments helpful in this case.
http://stackoverflow.com/questions/28497207/how-to-fail-a-script-assertion-in-soapui/28497531#284975...
Regards,
Rao.
http://stackoverflow.com/questions/28497207/how-to-fail-a-script-assertion-in-soapui/28497531#284975...
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2016
01:42 AM
08-17-2016
01:42 AM
Once again thank you so much @nmrao
Your comments solved my problem,
def error = [] if (jsonid != dbid) {error.add("jsonid : $jsonid is not equal to dbid: $dbid")} if (jsonname != dbname) {error.add("jsonname : $jsonname is not equal to dbname: $dbname")} assert error.size() == 0," $error " if(error.size() == 0){ log.info "Script Passed" }
