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/mean_time_reporter.rb,
lib/minitest/reporters/ruby_mate_reporter.rb

Defined Under Namespace

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

Constant Summary collapse

VERSION =
'1.4.2'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.reporters

Returns the value of attribute reporters


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

def reporters
  @reporters
end

Class Method Details

.choose_reporters(console_reporters, env)


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

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

.clock_time


73
74
75
76
77
78
79
# File 'lib/minitest/reporters.rb', line 73

def self.clock_time
  if minitest_version >= 561
    Minitest.clock_time
  else
    Time.now
  end
end

.minitest_version


81
82
83
# File 'lib/minitest/reporters.rb', line 81

def self.minitest_version
  Minitest::VERSION.delete('.').to_i
end

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


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

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!


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

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!


85
86
87
88
89
# File 'lib/minitest/reporters.rb', line 85

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)


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

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