Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you get rspec to print failed test backtraces *as* it is running?

Our test quite takes a while to run, and there is always this 5-10 minute period where we know which test has failed, but we can't see the failure message or backtrace until the suite finishes. It would be more efficient to see the backtraces as they happen. Is this possible?

like image 572
Brian Armstrong Avatar asked Jan 09 '13 07:01

Brian Armstrong


2 Answers

I use Fuubar to get immediate failure messages and backtraces while the suite continues, as well as get a more meaningful indicator of how far my test suite has progressed.

like image 58
Paul Fioravanti Avatar answered Sep 27 '22 18:09

Paul Fioravanti


You have two options:

1) fail fast

# spec/spec_helper.rb
RSpec.configure do |c|
  c.fail_fast = true
end

..or use it from the command line

$ bundle exec rspec spec/ --fail-fast
.F

Failures:
  1) Swinger should set the Capybara driver
     Failure/Error: Capybara.current_driver.should_not == :rack_test

Finished in 0.00479 seconds
2 examples, 1 failure

Basically this option on error will stop the test suite and it will print the error.

2) use rspec-instafail gem

https://github.com/grosser/rspec-instafail

This gem will show failing spec instantly and it will continue running specs.

like image 34
luacassus Avatar answered Sep 27 '22 17:09

luacassus