@Before
public void quit_if_tagged_scenario_failed(Scenario scenario) {
if (!isTagged(scenario) && prevScenarioFailed)
throw new IllegalStateException("An important scenario has failed! Cucumber wants to quit.");
}
I'm using this method to check if the previuos scenario failed. If failed I want to skip all the scenarios in that feature file.So the problem here is if I’m running two feature files the last scenario in the feature file failed and the first step of next feature will also fails because cucumbers previous scenario from past feature file is failed. Do you know how to handle that kind of situation? Your help will be greatly appreciated.
Cucumber scenarios should not be dependent on each other.
According to the Cucumber best practices, there shouldn’t be any sort of coupling between scenarios. Or in other words, there should be no state that persists between scenarios.
Just as an example why this is a bad practice consider a case when one scenario step adds a record to a database, while the subsequent scenarios depend on the existence of that record. This may work, but will create a problem if the order in which scenarios run changes, or they are run in parallel.
Try to review your approach and see how can you define your scenarios differently to avoid coupling. Good luck.