Cucumber BeforeStep

风格不统一 提交于 2020-01-03 08:26:31

问题


Is there a BeforeStep equivalent to AfterStep in Cucumber?

If not - has anyone found a solution / workaround?


回答1:


According to the documentation on Hooks on the Cucumber Wiki on GitHub, the answer is no. There is Before but no BeforeStep. Depending on what you are trying to achieve, Before might do what you need.




回答2:


So far as Before is executed before each scenario and AfterStep - after each step in scenario, to achieve BeforeStep you can simply place you code in both hooks: Before and AfterStep.




回答3:


I know it is quite outdated question but:

Before might be used explicitly e.g before scenario but sometimes it is pointles due to fact that it pollute scenarios description.

I use in support/hooks.rb e.g

Before do |scenario|
//something which should be executed before each scenario
end

It might be usefull in case when some action action must be repeted before EVERY scenario in test set.




回答4:


I am running cucumber within TestNG. I'd like to print the step definition names out as the feature file is processed. This doesn't appear to happen when running under TestNG. If I had a BeforesStep annotation on a method such as beforeStep(StepDefinition sd) (or something like that), I'd log the step definition name. That would ve very useful.

Is there a different way to do this with Java Cucumber ?



来源:https://stackoverflow.com/questions/1408239/cucumber-beforestep

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