Hook up in cucumber check for scenario failure in java

余生颓废 提交于 2019-12-08 03:45:22

问题


While I was reading how to add a cleanup for a cucumber scenario on failure I got this piece of code in the internet.

After do |s|
  if s.failed?
    #If you are on an iOS Device
        $driver.quit
         sleep(time_for_driver_ready)
    #else
         reset  
  end
end

This is in ruby. I am working in java and is there any way to implement s.failed? in java, because in java the after method declaration does not include a scenario variable.


回答1:


You can pass the Scenario as a parameter to the After hook, the framework will inject the current scenario object to the method.

@After
public void afterMethod(Scenario scenario) {
    if(scenario.isFailed()) {


    }
}


来源:https://stackoverflow.com/questions/44919810/hook-up-in-cucumber-check-for-scenario-failure-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!