Skip to content

--fail-fast does not bail if a failure happens during before(:all) #567

Closed
ferrous26 opened this Issue Jan 30, 2012 · 2 comments

4 participants

@ferrous26

As in this example, I would expect that RSpec stops at the first problem, which would be in the before(:all) block.

describe "Fail fast in a before all block" do
  before :all do
    raise RuntimeError
  end
  it "should bail at the first test" do
    1.should == 1
  end
  it "will bail here for sure" do
    1.should == 0
  end
end
@ferrous26 ferrous26 closed this Jan 31, 2012
@ferrous26 ferrous26 reopened this Jan 31, 2012
@wulftone

+1, also experiencing this on rspec version 2.11.0

@soulcutter soulcutter added a commit to soulcutter/rspec-core that referenced this issue Sep 4, 2012
@soulcutter soulcutter Fixed #567 superficially e5a3ae0
@soulcutter soulcutter added a commit to soulcutter/rspec-core that referenced this issue Sep 4, 2012
@soulcutter soulcutter Fixed #567 halt on toplevel before(:all) exceptions bf244f5
@soulcutter
RSpec member

Digging into this, I believe there may be two different issues.

  1. Reporting: The before(:all) exception is only raised once, but it reports it as a failure for all examples and descendant examples of the example group (via the fail_filtered_examples method). From some perspectives I think this is valid behavior. It may make it appear as though it's actually repeating the error multiple times, though (once for each example). As it turns out it could be a bit hairy to get "better" reporting on failures on the example groups themselves, as evidenced by the existing TODO to figure out a better way to deal with after(:all) errors... I took a shot at it, but I'm not sure it's preferable reporting-wise https://github.com/soulcutter/rspec-core/compare/before-all-fail-fast
  2. Not Halting on before(:all): IINM there is some inconsistency in with before(:all) exceptions not setting RSpec.wants_to_quit and so it will roll right on through to the next file or example group. Here's a fix for that issue, though I am open to suggestions on how to exercise this via a spec rather than a cuke https://github.com/soulcutter/rspec-core/compare/before-all-fail-fast2 since I'm not entirely sure that this is necessary for documentation

Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.