2015-05-07 37 views
1

我正在使用Minitest with Rails。Minitest首次失败时退出?

如果我正在运行一堆测试,如何在第一次失败时退出?我在编写测试时希望发生这种情况,因为后面的测试在失败之后运行是浪费时间。

+0

你可以只瞄准具体的测试?所以如果你有一个红色的,你可以运行特定的测试,直到它是绿色的? – abbott567

+0

@vgoff我正在运行Rails 4.1.6。我看到RSpec有一个'fail_fast'选项,所以我基本上想知道'Test :: Unit'是否有类似的选项。 –

+0

当你说Test :: Unit时,不确定你正在使用哪个库。你的意思是最小的?我想现在,Ruby版本也会有帮助,因为现在你真的不是在讨论Rails和Ruby以及库。 – vgoff

回答

0

您可以使用minitest-fail-fast宝石。报告失败后,您还可以将Minitest记者引擎修改为exit

0

我找到这个答案,而寻找解决方案,但至少在Rails的5.1你有一个选项:

rails test -h Usage: bin/rails test [options] [files or directories] 

You can run a single test by appending a line number to a filename: 

    bin/rails test test/models/user_test.rb:27 

You can run multiple files and directories at the same time: 

    bin/rails test test/controllers test/integration/login_test.rb 

By default test failures and errors are reported inline during a run. 

Rails options: 
    -w, --warnings     Run with Ruby warnings enabled 
    -e, --environment    Run tests in the ENV environment 
    -b, --backtrace     Show the complete backtrace 
    -d, --defer-output    Output test failures and errors after the test run 
    -f, --fail-fast     Abort test run on first failure or error 
    -c, --[no-]color     Enable color in the output 

所以你就只需要运行rails test -f