class Minitest::Display::Reporter
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/minitest/display.rb, line 142 def initialize(*args) super @total_assertions = 0 @total_errors = 0 @total_failures = 0 @total_tests = 0 end
Public Instance Methods
display_slow_suites()
click to toggle source
# File lib/minitest/display.rb, line 224 def display_slow_suites times = @test_times.map { |suite, tests| [suite, tests.map(&:last).inject {|sum, n| sum + n }] }.sort { |a, b| b[1] <=> a[1] } puts "Slowest suites:" times[0..display.options[:output_slow_suites].to_i].each do |suite, time| puts "%.2f s\t#{suite.name.gsub(/%/, '%%')}" % time end end
display_slow_tests()
click to toggle source
# File lib/minitest/display.rb, line 216 def display_slow_tests times = @test_times.values.flatten(1).sort { |a, b| b[1] <=> a[1] } puts "Slowest tests:" times[0..display.options[:output_slow].to_i].each do |test_name, time| puts "%.2f s\t#{test_name.gsub(/%/, '%%')}" % time end end
record(result)
click to toggle source
# File lib/minitest/display.rb, line 183 def record(result) suite = result.class if suite != @current_suite record_suite_finished(@current_suite) if @current_suite record_suite_started(suite) @assertions = 0 end @assertions += result.assertions @total_assertions += result.assertions @total_tests += 1 output = if result.error? @total_errors += 1 display.color(display.options[:print][:error], :error) elsif result.failure @total_failures += 1 display.color(display.options[:print][:failure], :failure) else display.color(display.options[:print][:success], :success) end print output @wrap_count -= 1 if @wrap_count == 0 print "\n#{' ' * @suite_header.length}#{display.options[:suite_divider]}" @wrap_count = @wrap_at end run_recorder_method(:record, suite, result.name, result.assertions, result.time, result.failure) @test_times[suite] << ["#{suite}##{result.name}", result.time] @current_suite = suite end
record_suite_finished(suite)
click to toggle source
# File lib/minitest/display.rb, line 161 def record_suite_finished(suite) @suite_finished = Time.now time = @suite_finished.to_f - @suite_started.to_f print "\n#{' ' * @suite_header.length}#{display.options[:suite_divider]}" print "%.2f s" % time run_recorder_method(:record_suite_finished, suite, @assertions, time) end
record_suite_started(suite)
click to toggle source
# File lib/minitest/display.rb, line 150 def record_suite_started(suite) if display.options[:suite_names] && display.printable_suite?(suite) @suite_header = suite.to_s print display.color("\n#{@suite_header}#{display.options[:suite_divider]}", :suite) @wrap_at = display.options[:wrap_at] - @suite_header.length @wrap_count = @wrap_at end @suite_started = Time.now run_recorder_method(:record_suite_started, suite) end
report()
click to toggle source
# File lib/minitest/display.rb, line 175 def report record_suite_finished(@current_suite) if @current_suite puts display_slow_tests if display.options[:output_slow] display_slow_suites if display.options[:output_slow_suites] run_recorder_method(:record_tests_finished, @total_tests, @total_assertions, @total_failures, @total_errors, Time.now.to_f - @tests_started) end
start()
click to toggle source
# File lib/minitest/display.rb, line 169 def start @test_times ||= Hash.new { |h, k| h[k] = [] } @tests_started = Time.now.to_f run_recorder_method(:record_tests_started) end
Private Instance Methods
display()
click to toggle source
# File lib/minitest/display.rb, line 241 def display ::Minitest::Display end
run_recorder_method(method, *args)
click to toggle source
# File lib/minitest/display.rb, line 233 def run_recorder_method(method, *args) Minitest::Display.recorders.each do |recorder| if recorder.respond_to?(method) recorder.send method, *args end end end