Module: Minitest::Reporters

Defined in:
lib/minitest/reporters.rb,
lib/minitest/reporters/ansi.rb,
lib/minitest/reporters/version.rb,
lib/minitest/reporters/base_reporter.rb,
lib/minitest/reporters/html_reporter.rb,
lib/minitest/reporters/spec_reporter.rb,
lib/minitest/minitest_reporter_plugin.rb,
lib/minitest/reporters/junit_reporter.rb,
lib/minitest/reporters/default_reporter.rb,
lib/minitest/reporters/progress_reporter.rb,
lib/minitest/reporters/ruby_mate_reporter.rb

Defined Under Namespace

Modules: ANSI Classes: BaseReporter, DefaultReporter, DelegateReporter, HtmlReporter, JUnitReporter, ProgressReporter, RubyMateReporter, SpecReporter

Constant Summary collapse

VERSION =
'1.1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.reporters

Returns the value of attribute reporters.



21
22
23
# File 'lib/minitest/reporters.rb', line 21

def reporters
  @reporters
end

Class Method Details

.choose_reporters(console_reporters, env)



60
61
62
63
64
65
66
67
68
# File 'lib/minitest/reporters.rb', line 60

def self.choose_reporters(console_reporters, env)
  if env["TM_PID"]
    [RubyMateReporter.new]
  elsif env["RM_INFO"] || env["TEAMCITY_VERSION"]
    [RubyMineReporter.new]
  elsif !env["VIM"]
    Array(console_reporters)
  end
end

.use!(console_reporters = ProgressReporter.new, env = ENV, backtrace_filter = nil)



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/minitest/reporters.rb', line 24

def self.use!(console_reporters = ProgressReporter.new, env = ENV, backtrace_filter = nil)
  use_runner!(console_reporters, env)
  if backtrace_filter.nil? && !defined?(::Rails)
    backtrace_filter = ExtensibleBacktraceFilter.default_filter
  end
  Minitest.backtrace_filter = backtrace_filter unless backtrace_filter.nil?

  unless defined?(@@loaded)
    use_around_test_hooks!
    use_old_activesupport_fix!
    @@loaded = true
  end
end

.use_around_test_hooks!



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/minitest/reporters.rb', line 42

def self.use_around_test_hooks!
  Minitest::Test.class_eval do
    def run_with_hooks(*args)
      if defined?(Minitest::Reporters) && reporters = Minitest::Reporters.reporters
        reporters.each { |r| r.before_test(self) }
        result = run_without_hooks(*args)
        reporters.each { |r| r.after_test(self) }
        result
      else
        run_without_hooks(*args)
      end
    end

    alias_method :run_without_hooks, :run
    alias_method :run, :run_with_hooks
  end
end

.use_old_activesupport_fix!



70
71
72
73
74
# File 'lib/minitest/reporters.rb', line 70

def self.use_old_activesupport_fix!
  if defined?(ActiveSupport::VERSION) && ActiveSupport::VERSION::MAJOR < 4
    require "minitest/old_activesupport_fix"
  end
end

.use_runner!(console_reporters, env)



38
39
40
# File 'lib/minitest/reporters.rb', line 38

def self.use_runner!(console_reporters, env)
  self.reporters = choose_reporters(console_reporters, env)
end