Is there a BeforeStep equivalent to AfterStep in Cucumber?
If not - has anyone found a solution / workaround?
Is there a BeforeStep equivalent to AfterStep in Cucumber?
If not - has anyone found a solution / workaround?
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.
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.
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.
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 ?