Class: Asciidoctor::DocTest::TestReporter
- Inherits:
-
Minitest::StatisticsReporter
- Object
- Minitest::StatisticsReporter
- Asciidoctor::DocTest::TestReporter
- Defined in:
- lib/asciidoctor/doctest/test_reporter.rb
Overview
This class is responsible for printing a formatted output of the test run.
Defined Under Namespace
Modules: ResultExt
Instance Method Summary collapse
- #aggregated_results ⇒ Object
-
#passes ⇒ Integer
Number of passed tests (examples).
- #record(result) ⇒ Object
-
#report ⇒ Object
Outputs the summary of the run.
- #start ⇒ Object
- #summary ⇒ Object
-
#verbose? ⇒ Boolean
Whether verbose mode is enabled.
Instance Method Details
#aggregated_results ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/asciidoctor/doctest/test_reporter.rb', line 50 def aggregated_results filtered_results = verbose? ? results : results.reject(&:skipped?) return nil if filtered_results.empty? str = String.new("Aggregated results:\n") filtered_results.each do |res| str << "\n#{res.symbol} #{res.failure.result_label}: ".color(res.color) str << "#{res.name}\n#{res.failure..indent(3)}\n\n" end str end |
#passes ⇒ Integer
Returns number of passed tests (examples).
85 86 87 |
# File 'lib/asciidoctor/doctest/test_reporter.rb', line 85 def passes count - failures - errors - skips end |
#record(result) ⇒ Object
Note:
Overrides method from Minitest::StatisticsReporter
.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/asciidoctor/doctest/test_reporter.rb', line 28 def record(result) result.extend ResultExt if verbose? io.puts [ result.symbol.color(result.color), result.name ].join(' ') else io.print result.result_code.color(result.color) end super end |
#report ⇒ Object
Note:
Overrides method from Minitest::StatisticsReporter
.
Outputs the summary of the run.
43 44 45 46 47 |
# File 'lib/asciidoctor/doctest/test_reporter.rb', line 43 def report super io.puts unless verbose? # finish the dots io.puts ['', aggregated_results, summary, ''].compact.join("\n") end |
#start ⇒ Object
Note:
Overrides method from Minitest::StatisticsReporter
.
20 21 22 23 |
# File 'lib/asciidoctor/doctest/test_reporter.rb', line 20 def start super io.puts "\n" + ([:title] || 'Running DocTest:') + "\n\n" end |
#summary ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/asciidoctor/doctest/test_reporter.rb', line 65 def summary str = String.new("#{count} examples (") str << [ ("#{passes} passed".color(:green) if passes > 0), ("#{failures} failed".color(:red) if failures > 0), ("#{errors} errored".color(:yellow) if errors > 0), ("#{skips} skipped".color(:cyan) if skips > 0) ].compact.join(', ') + ")\n\n" str << "Finished in %.3f s.\n" % total_time if results.any?(&:skipped?) && !verbose? str << "\nYou have skipped tests. Run with VERBOSE=yes for details.\n" end str end |
#verbose? ⇒ Boolean
Returns whether verbose mode is enabled.
91 92 93 |
# File 'lib/asciidoctor/doctest/test_reporter.rb', line 91 def verbose? !![:verbose] end |