How to Exit if the Assertion fails in JUnit / Cucumber | Selenium Forum
M
Posted on 13/05/2016
Hi Ashish / All,

I have an situation where I Have all the test steps are written in the Cucumber Annotation, Given, when then...

1) I have the Assertion in JUnit ( Cucumber) how to come out from Program so that It should NOT execute the other annotation below in the code.....
I tried all the ways like throw , return in the try / catch block but its executing the other annotations too...

Please find the attached sample (1.png)... My object here is to if the Assertion is Found, I Dont want to execute further annotations below. Which is the best way approach ?

[attachment=1:103cxhe4]1.PNG[/attachment:103cxhe4]

2) For the same test case, I have a feature file where Run Mode set for first test case to N and second test case to Y, In my .java file with new pending options First test case run successfully with Skipping

However for Second its throwing with Exception as the Browser is Closed its NOT reopening the browser again.

[attachment=0:103cxhe4]2.PNG[/attachment:103cxhe4]

Appreciate if any suggestion / pointers on the above issue ?

Thanks

Regards
J

M
Replied on 14/05/2016

if you want execution to stop then don't put assert in try catch.