I want to continue executing my scenarios even if some fail in between in the cucumber report it should show it as a failure but should not stop the execution.
I tried using soft assertion class and using this
SoftAssertion sa = new SoftAssertion();
if (response.getStatusCode() == 200) {
Sytem.out.println("pAASED")
} else {
sa.fail("this is the failure");
}
but suppose I have two scenarios and for the first one the response is not 200 it is going to else block and failing the scenario
java.lang.AssertionError: this is the failure
at org.junit.Assert.fail(Assert.java:88)
it is not even going for the second scenario. Can someone help how can I achieve the expected result(ie it should continue the execution irrespective of one getting failed)
Here you have two different things.
As per definition of exception from Oracle website :
An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions.
In this way exception is totally different from normal flow of execution. So if you want to proceed even in case of exception you need to use the concept of exception handling . As below:
try {
response = yourMethodCall();
} catch (Exception e) {
log.error(e)
}
In above sample code:
yourMethodCall()
with actual method call.AssertionError
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.