When I run something in the Before hook it seems to happen after the first Given step.
Scenario: Stack Overflow Example
Given some condition
When something happens
Then something should be
Before do
puts 'hello'
end
Outputs:
Scenario: Stack Overflow Example
Given some condition
Hello
....
This happens for each step.
Is this a misunderstanding on my part or a cucumber feature? How do I run something before the given step?
Many thanks in advance.
R
I don’t know the technical reason but cucumber wont print using a plain ‘puts’ statement until after the scenario is finished.
Try STDOUT.puts “hello” and you will see that the Before hook runs first.