Module: Minitest::Reporters

Defined in:
lib/minitest/reporters.rb,
lib/minitest/reporters/ansi.rb,
lib/minitest/reporters/version.rb,
lib/minitest/reporters/spec_reporter.rb,
lib/minitest/reporters/base_reporter.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, JUnitReporter, ProgressReporter, RubyMateReporter, SpecReporter

Constant Summary collapse

VERSION =
'1.0.11'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.reporters

Returns the value of attribute reporters


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

def reporters
  @reporters
end

Class Method Details

.choose_reporters(console_reporters, env)


56
57
58
59
60
61
62
63
64
# File 'lib/minitest/reporters.rb', line 56

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

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


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

def self.use!(console_reporters = ProgressReporter.new, env = ENV, backtrace_filter = ExtensibleBacktraceFilter.default_filter)
  use_runner!(console_reporters, env)
  Minitest.backtrace_filter = backtrace_filter

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

.use_around_test_hooks!


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/minitest/reporters.rb', line 38

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!


66
67
68
69
70
# File 'lib/minitest/reporters.rb', line 66

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)


34
35
36
# File 'lib/minitest/reporters.rb', line 34

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