自定义 Minitest 输出以咆哮

Customize Minitest output to growl

在我的 rails 应用程序中,我正在使用:

当测试在后台运行时:

我从 Growl 那里得到这个:

很高兴知道至少有一项测试失败了。有什么方法可以添加报告数字的摘要,即 2 次失败等?

您可以通过修改 Guard::Minitest::Notifier.notify:

来更改行为
require 'guard/compat/plugin'

module Guard
  class Minitest < Plugin
    class Notifier
      # ...
      def self.notify(test_count, assertion_count, failure_count, error_count, skip_count, duration)
        message = guard_message(test_count, assertion_count, failure_count, error_count, skip_count, duration)
        image   = guard_image(failure_count + error_count, skip_count)

        # title: was just 'Minitest results'
        Compat::UI.notify(message, title: message, image: image)
      end
    end
  end
end

标题 'Minitest results' 很可能只是一个杂乱的占位符。此示例将其设置为与您在 CLI 中获得的输出相同的输出,但您实际上可以在这里做任何您想做的事情。

您最好通过分叉 gem 并将您的 gem 文件设置为从您的分叉中提取。

gem 'minitest-guard', github: 'yourusername/minitest-guard'