Reputation: 1
I am following POM approach with Testng for designing my framework . Consider a scenario wherein the test case got failed in the nth test step inside a @Test method.Can anyone suggest how can I skip the remaining test steps(from n+1 onwards)?
Since I am automating the manual test cases, each @Test belongs to 1 test case and so I cannot split up the steps into multiple @Test methods. When the test step is failed, it needs to skip the next steps in that @Test method and proceed to the next test case.
Also I need the count of test steps skipped in the result.
Kindly help.
Upvotes: 0
Views: 1646
Reputation: 14746
Looks like you are basically looking for something around what a BDD tool such as Cucumber provides you. Cucumber lets you create a .feature
file which contains one or more scenario
(You can visualize each of your scenario
to be one @Test
annotated test method).
You could then leverage one of the Cucumber integrations i.e.,
Choose either JUnit (or) Choose TestNG integration
and let one of these run your BDD tests.
Here when a particular step fails, then all subsequent steps would be aborted (which is what you are asking for)
Outside of Cucumber, I dont think you can have this done via any other mechanism. The reporting needs (such as how many steps were skipped etc.,) can be fulfilled by any cucumber based reports.
You should start from here : http://docs.cucumber.io/guides/10-minute-tutorial/
Upvotes: 1