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
}
COLOR =
{
  red: 31,
  green: 32,
  yellow: 33,
  blue: 34
}

Instance Method Summary collapse

Constructor Details

#initializeReporter

Returns a new instance of Reporter.



18
19
20
21
# File 'lib/minitest/utils/reporter.rb', line 18

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

Instance Method Details

#record(result) ⇒ Object



23
24
25
26
# File 'lib/minitest/utils/reporter.rb', line 23

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

#reportObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/minitest/utils/reporter.rb', line 36

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) {|result, index| display_failing(result, index) }
    skipped_results.each.with_index(failing_results.size + 1) {|result, index| display_skipped(result, index) }
  end

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

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

#startObject



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

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