Class: Minitest::Reporters::FailReporter
- Inherits:
-
Object
- Object
- Minitest::Reporters::FailReporter
- Includes:
- ANSI::Code, Minitest::RelativePosition, Minitest::Reporter
- Defined in:
- lib/minitest/reporters/fail.rb
Overview
A reporter based on minitest-emoji by tenderlove
and on minitest-reporters by CapnKernul
Constant Summary collapse
- EMOJI =
{ 'P' => "\u{1F49A} ", # heart 'E' => "\u{1f525} ", # flame 'F' => "\u{1f4a9} ", # poop 'S' => "\u{1f37a} " # beer }
Instance Method Summary collapse
- #after_suite(suite) ⇒ Object
- #after_suites(suites, type) ⇒ Object
- #after_test(suite, test) ⇒ Object
- #before_suite(suite) ⇒ Object
- #before_suites(suite, type) ⇒ Object
- #before_test(suite, test) ⇒ Object
- #error(suite, test, test_runner) ⇒ Object
- #failure(suite, test, test_runner) ⇒ Object
- #init_counts ⇒ Object
- #init_suite_counts ⇒ Object
-
#initialize(opts = {}) ⇒ FailReporter
constructor
A new instance of FailReporter.
- #pass(suite, test, test_runner) ⇒ Object
- #skip(suite, test, test_runner) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ FailReporter
Returns a new instance of FailReporter.
28 29 30 31 32 |
# File 'lib/minitest/reporters/fail.rb', line 28 def initialize(opts = {}) @emoji = EMOJI.merge(opts.fetch(:emoji, {})) init_counts init_suite_counts end |
Instance Method Details
#after_suite(suite) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# 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) ⇒ Object
56 57 58 59 60 61 62 |
# 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) ⇒ Object
90 91 92 93 |
# File 'lib/minitest/reporters/fail.rb', line 90 def after_test(suite,test) @test_count += 1 @suite_test_count += 1 end |
#before_suite(suite) ⇒ Object
64 65 66 |
# File 'lib/minitest/reporters/fail.rb', line 64 def before_suite(suite) init_counts end |
#before_suites(suite, type) ⇒ Object
52 53 54 |
# File 'lib/minitest/reporters/fail.rb', line 52 def before_suites(suite, type) init_suite_counts end |
#before_test(suite, test) ⇒ Object
80 81 82 83 84 85 86 87 88 |
# 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) ⇒ Object
114 115 116 117 118 119 120 |
# 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) ⇒ Object
106 107 108 109 110 111 112 |
# 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 ⇒ Object
43 44 45 46 47 48 49 50 |
# 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 ⇒ Object
34 35 36 37 38 39 40 41 |
# 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) ⇒ Object
95 96 97 |
# File 'lib/minitest/reporters/fail.rb', line 95 def pass(suite, test, test_runner) @results['P'] += 1 end |
#skip(suite, test, test_runner) ⇒ Object
99 100 101 102 103 104 |
# 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 |