cucumber-ruby icon indicating copy to clipboard operation
cucumber-ruby copied to clipboard

After hook not executing when scenario outline example fails

Open vbyjsue opened this issue 12 years ago • 4 comments

cucumber v1.3.14 ruby 1.9.3 @448

When a scenario outline example fails because of an RSpec::Expectations::ExpectationNotMetError, the after-hook is never executed. In scenario it works as expected.

Scenario Outline: Failing example
    When 1 equals <number>
    Then the example should pass
    Example: |number|
           |1       |
           |2       |
When (/^(\d) equals (\d)$/) do |number1, number2|
    number1.should == number2
end
After do |scenario|
  if scenario.failed?
    raise "Something went wrong and I want to add additional info, but it doesn't work"
  end
end

vbyjsue avatar Apr 23 '14 14:04 vbyjsue

Was this recently introduced?

Do we know if this fails in an earlier version of cucumber? I've suddenly been seeing instances were stuff did not take screenshots on failure (part of our after hook code), and am wondering if this is the cause.

Is the problem that it is not executing the after, or is the problem perhaps that scenario.failed is not true?

Chuckv avatar May 05 '14 17:05 Chuckv

Hi Chuck,

The existing code in production has a whole load of issues like this (e.g. https://github.com/cucumber/cucumber/issues/560, https://github.com/cucumber/cucumber/issues/52) which is why we've embarked on a rewrite of the internals for version 2.0 (on master)

I'd assume this is working in that master branch, but I'd appreciate someone checking.

mattwynne avatar May 06 '14 06:05 mattwynne

Please re-test with cucumber v 2.0.0.beta.1 and re-open if this is still a problem.

mattwynne avatar Aug 25 '14 09:08 mattwynne

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Oct 25 '18 06:10 lock[bot]