Open Fedcomp opened 8 years ago
I don't use notification myself, but I'm guessing people use notification to know "if tests finished".
But it seems useful to opt out.
I don't know what notification backend you're using (depends on your OS and settings), but I think this could be a generic feature.
If you like, you can quickly hack a solution yourself and then send a PR if it works.
I'm not sure what kind of API/configuration would be best, but let's say it's:
notification(:tmux, {
ignored_notifications: [:success] # < ---- maybe an option like this?
success: 'colour150',
failure: 'colour174',
pending: 'colour179',
}) if ENV['TMUX']
And then in:
You'd skip the _perform_notify
if the current notification type is in the "ignored" list.
As I use minitest-reporter
gem, I made a monkey patch in my test_helper.rb file.
module NofityFailureTest
def record(test)
super
if test.error? || test.failure
e = test.failure
TerminalNotifier::Guard.notify(e.message, title: File.basename(e.location))
end
end
end
module Minitest
module Reporters
class BaseReporter
include NofityFailureTest if RUBY_PLATFORM =~ /darwin/ && `which terminal-notifier`.present?
end
end
end
You can monkey patch minitest gem If you like. It's in Minitest::Reporters::BaseReporter
.
Could be there option to display notification only when tests fail? Right now it spams me with every running, even if tests are not failing.