你怎么能让rspec打印失败的测试回溯*因为它正在运行?

时间:2013-01-09 07:17:07

标签: rspec rspec2 rspec-rails guard

我们的测试需要一段时间才能运行,并且总是有5-10分钟的时间我们知道哪个测试失败了,但是在套件完成之前我们看不到失败消息或回溯。在它们发生时看到回溯会更有效。这可能吗?

2 个答案:

答案 0 :(得分:11)

您有两种选择:

1)快速失败

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

..或从命令行使用它

$ 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

基本上这个错误选项会停止测试套件,它会打印错误。

2)使用rspec-instafail gem

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

此宝石将立即显示失败的规格,并将继续运行规格。

答案 1 :(得分:6)

我继续使用Fuubar来获取即时失败消息和回溯,并获得一个更有意义的指标,指出我的测试套件的进展程度。

相关问题