class Minitest::Reporters::FailReporter
A reporter based on minitest-emoji by tenderlove
and on minitest-reporters by CapnKernul
@see github.com/tenderlove/minitest-emoji @see github.com/CapnKernul/minitest-reporters
Constants
- EMOJI
Public Class Methods
new(opts = {})
click to toggle source
# File lib/minitest/reporters/fail.rb, line 28 def initialize(opts = {}) @emoji = EMOJI.merge(opts.fetch(:emoji, {})) init_counts init_suite_counts end
Public Instance Methods
after_suite(suite)
click to toggle source
# File lib/minitest/reporters/fail.rb, line 68 def after_suite(suite) if @test_count > 1 @suites_results.each_key { |k| @suites_results[k] += @results[k] } puts "#{@test_count} Tests - #{suite}" %w(P E F S).each do |status| print("#{@emoji[status]} => " + @emoji[status]*@results[status] + " #{@results[status]}") puts; end end end
after_suites(suites, type)
click to toggle source
# File lib/minitest/reporters/fail.rb, line 56 def after_suites(suites, type) puts "FINISHED - #{@suites_test_count} tests ran" %w(P E F S).each do |status| print("#{@emoji[status]} => " + @emoji[status]*@suites_results[status] + " #{@suites_results[status]}") puts; end end
after_test(suite,test)
click to toggle source
# File lib/minitest/reporters/fail.rb, line 90 def after_test(suite,test) @test_count += 1 @suite_test_count += 1 end
before_suite(suite)
click to toggle source
# File lib/minitest/reporters/fail.rb, line 64 def before_suite(suite) init_counts end
before_suites(suite, type)
click to toggle source
# File lib/minitest/reporters/fail.rb, line 52 def before_suites(suite, type) init_suite_counts end
before_test(suite,test)
click to toggle source
# File lib/minitest/reporters/fail.rb, line 80 def before_test(suite,test) #FIX_FOR_ZEUS!! (which seems to want to run tests twice) # on the second run, # these are still nil, # for some reason # oh i wish i knew why! @test_count ||= 0 @suite_test_count ||= 0 end
error(suite,test,test_runner)
click to toggle source
# File lib/minitest/reporters/fail.rb, line 114 def error(suite,test,test_runner) @results['E'] += 1 puts; print(@emoji['E'] + red { pad_mark("#{print_time(test)} ERROR") } ) puts; print(red { pad_mark(suite) } ) puts; print(red { pad_mark(test) } ) puts; print_info(test_runner.exception) end
failure(suite,test,test_runner)
click to toggle source
# File lib/minitest/reporters/fail.rb, line 106 def failure(suite,test,test_runner) @results['F'] += 1 puts; print(@emoji['F'] + red { pad_mark("#{print_time(test)} FAIL") } ) puts; print(red { pad_mark(suite) } ) puts; print(red { pad_mark(test) } ) puts; print_info(test_runner.exception) end
init_counts()
click to toggle source
# File lib/minitest/reporters/fail.rb, line 43 def init_counts @test_count = 0 @results = { 'P' => 0, 'E' => 0, 'F' => 0, 'S' => 0 } end
init_suite_counts()
click to toggle source
# File lib/minitest/reporters/fail.rb, line 34 def init_suite_counts @suites_test_count = 0 @suites_results = { 'P' => 0, 'E' => 0, 'F' => 0, 'S' => 0 } end
pass(suite, test, test_runner)
click to toggle source
# File lib/minitest/reporters/fail.rb, line 95 def pass(suite, test, test_runner) @results['P'] += 1 end
skip(suite, test, test_runner)
click to toggle source
# File lib/minitest/reporters/fail.rb, line 99 def skip(suite, test, test_runner) @results['S'] += 1 puts; print(@emoji['S'] + yellow { pad_mark("#{print_time(test)} SKIP") } ) puts; print(yellow { pad_mark(suite) } ) puts; print(yellow { pad_mark(test) } ) end
Private Instance Methods
print_info(e)
click to toggle source
# File lib/minitest/reporters/fail.rb, line 129 def print_info(e) e.message.each_line { |line| print_with_info_padding(line) } trace = filter_backtrace(e.backtrace) trace.each { |line| print_with_info_padding(line) } end
print_time(test)
click to toggle source
# File lib/minitest/reporters/fail.rb, line 124 def print_time(test) total_time = Time.now - (runner.test_start_time || Time.now) " (%.2fs)" % total_time end