gpt4 book ai didi

ruby - 如何让minitest在失败时停止执行?

转载 作者:数据小太阳 更新时间:2023-10-29 06:50:09 26 4
gpt4 key购买 nike

我使用 Minitest 作为我的功能测试的运行程序,使用 Selenium 作为驱动程序来运行浏览器。每个测试都建模为 MiniTest::Unit::TestCase。

Minitest 在完成所有测试时报告执行摘要。遇到的异常也会在执行结束时打印出来。当由于执行上下文丢失而导致意外失败时,我发现很难调试。我遇到的异常不是确定性的。

有没有办法让 Minitest runner 在出现异常或断言失败时停止执行测试?

我正在使用 minitest (2.11.2) 和 ruby​​ 1.9.2p290 (2011-07-09) [i386-mingw32]

最佳答案

我认为您的意思是提供“快速失败”选项。我找到了 fail_fast for minitest (Test::Unit): Immediate backtrace & exit文章,但那已经过时了(仍然涵盖了可以做什么)。我认为您需要对您的测试库进行 monkeypatch 以启用此选项。我找到了一个要点,展示了如何 add a simple fail-fast option to minitest/turn/minitest-rails这样可能会让您走上正确的轨道。我知道您的问题与我引用的第一篇文章有​​关:

When I run the Test::Unit suite in my Ruby on Rails 3 project through rake test and a test is failing, the default behavior is to just print “F” or “E”, keep running until all the tests are finished (while I twiddle my thumbs), and only then print out a stack trace.

关于ruby - 如何让minitest在失败时停止执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9627859/

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