LukasMac LukasMac - 3 months ago 31
Ruby Question

Is there a cucumber hook to run before and after each feature

Is there a way to run specific code block before and after each cucumber feature with certain tag?

Since setup process is very expensive I don't want to run it before each scenario.


Few days ago I've spoke with Matt Wynne (one of the core team member of cucumber gem) and he told me that there is no such feature in cucumber (at the time of writing this).

As a workaround he suggested to tag whole feature and use before each hook with a flag like so:

Before('@feature_with_expensive_setup') do
  unless @setup_is_done
    # perform expensive setup code here ..
    @setup_is_done = true