On Tue, May 26, 2009 at 7:58 PM, David Chelimsky <dchelim...@gmail.com> wrote: > On Tue, May 26, 2009 at 7:33 PM, Gary Lin <g...@employees.org> wrote: >> Hi, >> >> I wonder if there is any way to tell the test script to continue even when >> encountering an assertion failure? The reason I am asking this is because I >> have a test flow that can take a long time to run and it would be very >> useful if I can perform all verification at the end of test flow in one shot >> rather than fail one and exit immediately. Of course, I could break each >> verification point into separate test case, but then it will double or >> triple the overall execution time. Does RSpec support this? > > Nope. RSpec is all about isolated examples of small bits of behaviour.
I don't mean there is no way to do it, btw. Just that RSpec doesn't offer a way out of the box. Each example is, essentially, run in a begin/rescue block. RSpec expectation matchers raise errors on failure. To get what you're after, you *could* write some sort of wrapper like this: def report_later(&block) begin yield rescue Exception => e # report the error somewhere but don't raise end end describe Something do it "should do something" do report_later do # example code with expectations go here end end end If you do this, though, you're really working against the intent of RSpec. The trick about having a series of expectations within one example is that if one fails early, you can't really trust the state of everything that comes after. This is one reason why RSpec is designed the way it is - to focus on one expectation in each example. HTH, David > >> >> Thanks, >> >> --Gary _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users