Class: Minitest::Utils::Reporter

Inherits:
StatisticsReporter
  • Object
show all
Defined in:
lib/minitest/utils/reporter.rb

Constant Summary collapse

COLOR_FOR_RESULT_CODE =
{
  "." => :green,
  "E" => :red,
  "F" => :red,
  "S" => :yellow
}.freeze
COLOR =
{
  red: 31,
  green: 32,
  yellow: 33,
  blue: 34
}.freeze

Instance Method Summary collapse

Constructor Details

#initializeReporter

Returns a new instance of Reporter.



20
21
22
23
# File 'lib/minitest/utils/reporter.rb', line 20

def initialize(*)
  super
  @color_enabled = io.respond_to?(:tty?) && io.tty?
end

Instance Method Details

#record(result) ⇒ Object



25
26
27
28
# File 'lib/minitest/utils/reporter.rb', line 25

def record(result)
  super
  print_result_code(result.result_code)
end

#reportObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/minitest/utils/reporter.rb', line 38

def report
  super
  io.sync = true

  failing_results = results.reject(&:skipped?)
  skipped_results = results.select(&:skipped?)

  color = :green
  color = :yellow if skipped_results.any?
  color = :red if failing_results.any?

  if failing_results.any? || skipped_results.any?
    failing_results.each.with_index(1) do |result, index|
      display_failing(result, index)
    end

    skipped_results
      .each
      .with_index(failing_results.size + 1) do |result, index|
      display_skipped(result, index)
    end
  end

  io.print "\n\n"
  io.puts statistics
  io.puts color(summary, color)

  return unless failing_results.any?

  io.puts "\nFailed Tests:\n"
  failing_results.each {|result| display_replay_command(result) }
  io.puts "\n\n"
end

#startObject



30
31
32
33
34
35
36
# File 'lib/minitest/utils/reporter.rb', line 30

def start
  super
  io.puts "Run options: #{options[:args]}"
  io.puts
  io.puts "# Running:"
  io.puts
end