Reputation: 27
i need to validate many assertions in same script assertion. But when any one of assert fails, runner stops there itself and control passed to next step. Below is my case
assert (1 ==1);
log.info "1";
assert (1 == 2);
log.info "2";
assert (1 ==3);
log.info "3";
When i execute the above, 2nd assertion fails and third assertion did not executed at all. Is there is any way to validate all assertions.
Upvotes: 1
Views: 351
Reputation: 1454
As usual, Steen has submitted a good answer (up-voted).
In my test suites, I have some tests where I want SoapUI to stop where there is a fail (e.g. assert). I have other tests where I want the test to continue where there is fail. To implement this, I usually have some Groovy script to do the result check. E.g. Pass/Fail. I then use a data-sink step to record each test's details with the result. I can then view the results in Excel for test reporting.
Upvotes: 1
Reputation: 873
Something like this could work:
java.util.ArrayList<String> failedAssertions = new java.util.ArrayList<String>()
def allAssertionsPassed = true
if (!1==1) {
failedAssertions.add("1==1")
allAssertionsPassed = false
}
if (!1==2) {
failedAssertions.add("1==2")
allAssertionsPassed = false
}
if (!1==3) {
failedAssertions.add("1==3")
allAssertionsPassed = false
}
if (!allAssertionsPassed ) {
log.info "Failed assertions:"
for (def s : failedAssertions) {
log.info s
}
}
assert(allAssertionsPassed)
Upvotes: 1