繁体   English   中英

首次失败时退出Minitest吗?

[英]Minitest Exit on first failure?

我正在使用Minitest和Rails。

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

您可能可以使用minitest-fail-fast gem。 您也可以将Minitest报告程序引擎修改为报告失败后exit

我只是在搜索解决方案时找到了这个答案,但是至少在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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM