自定义最小测试消息

Customize minitest messages

有没有办法自定义测试报告。目前我在每次测试结束时得到这一行:

3 tests, 0 assertions, 0 failures, 0 errors, 0 skips

我想在此行中包含测试文件名。

Minitest 有一个详细选项,可以显示每个 运行 测试的测试名称和执行时间。将 -v 标志传递给 Minitest 的方式会有所不同,具体取决于您 运行 测试的方式。有关详细输出的示例,请参阅 http://chriskottom.com/blog/2014/12/command-line-flags-for-minitest-in-the-raw/

另一种选择是将 minitest-reporters 与 SpecReporter 一起使用,方法是将其添加到您的 Gemfile 并将其放入您的测试助手中:

require "minitest/reporters"
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new

有关详细信息,请参阅 https://github.com/kern/minitest-reporters