gpt4 book ai didi

ruby-on-rails - Minitest 第一次失败退出?

转载 作者:行者123 更新时间:2023-12-05 04:15:55 25 4
gpt4 key购买 nike

我在 Rails 中使用 Minitest。

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

最佳答案

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

关于ruby-on-rails - Minitest 第一次失败退出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30092572/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com