Cucumber BeforeStep

2019-06-16 21:36发布

Is there a BeforeStep equivalent to AfterStep in Cucumber?

If not - has anyone found a solution / workaround?

标签: ruby cucumber
4条回答
仙女界的扛把子
2楼-- · 2019-06-16 21:49

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.

查看更多
Melony?
3楼-- · 2019-06-16 21:58

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楼-- · 2019-06-16 22:08

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 ?

查看更多
劳资没心,怎么记你
5楼-- · 2019-06-16 22:12

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.

查看更多
登录 后发表回答