NullVoxPopuli
NullVoxPopuli

Reputation: 65183

Cucumber: How do I enable a hook with a command line parameter?

I have this hook here: After do |scenario| if scenario.try(:status) == :failed @fail_count = @fail_count.to_i + 1 save_and_open_page if @fail_count <= 5 end

but I don't want it to always open failed scenarios.

Is there a way I can set up my cucumber such that when I do cucumber vars ... enable_open_page the above hook enables?

Upvotes: 1

Views: 164

Answers (1)

dexter
dexter

Reputation: 13593

After do |scenario| 
  if scenario.try(:status) == :failed 
    @fail_count = @fail_count.to_i + 1 
    save_and_open_page if ENV["ENABLE_OPEN_PAGE"].present? and @fail_count <= 5 
  end
end

And call cucumber with the environment variable:

ENABLE_OPEN_PAGE=true cucumber

Upvotes: 2

Related Questions