测试 怎样在 RSpec 测试正在运行的时候,列出已经出错的 error messages,而不用等到所有的测试都运行完成

chenyunli · November 16, 2017 · Last by chenyunli replied at November 20, 2017 · 6182 hits

我记得 minitest 可以在 控制台 中用快捷键 ctrl + t 查看正在运行的测试错误,但是 rsepc,查看不了,想请教一下大家有知道的么?不然运行测试,要等到所有测试都运行完才能查看到错误,太慢了。

可以缩小测试的范围,比如 rspec spec/controllers/users_controller.rb:23,

你不可能每次写完一个测试就把所有测试都跑一遍吧

Reply to 42thcoder

这种方法还是要等

Reply to Awlter1

额,好吧

不写测试。。。😂

两个方法:

  1. fail fast

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

    或者在运行时加参数 bundle exec rspec spec/ --fail-fast

  2. rspec-instafail gem 这个 gem 可以实时显示 error messages 并且测试会继续跑

  3. fuubar 好像也可以,没试过

Reply to rennyallen

好的,我试试

You need to Sign in before reply, if you don't have an account, please Sign up first.