What is the cucumber-jvm equivalent of Cucumber.wants_to_quit?

后端 未结 3 1961
一向
一向 2021-01-28 05:01

I am writing tests using cucumber-jvm and I want the system to stop running tests on the first scenario that fails. I found example code written for Cucumber Ruby that does thi

3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-28 05:38

    Creating cucumber hooks in the step definition file helps to stop the test after a scenario fails. This involves creating @Before and @After methods. Take a look at this example:

    @Before
      public void setUp() {
        if (prevScenarioFailed) {
          throw new IllegalStateException("Previous scenario failed!");
        }
    
    
      }
    
      @After()
      public void stopExecutionAfterFailure(Scenario scenario) {
        prevScenarioFailed = scenario.isFailed();
      }
    

提交回复
热议问题