Class: Roby::Test::MinitestReporter
- Inherits:
-
Minitest::SummaryReporter
- Object
- Minitest::SummaryReporter
- Roby::Test::MinitestReporter
- Defined in:
- lib/roby/test/minitest_reporter.rb
Overview
Minitest reporter aware of how exceptions should be displayed in Roby
Instance Method Summary collapse
-
#aggregated_results(io) ⇒ Object
Overload of Minitest::SummaryReporter#aggregated_results.
-
#failure_message(failure) ⇒ String
Generate a message for a test failure.
-
#result_to_s(result) ⇒ String
Generate the string to display for a given test result.
-
#roby_exception?(failure) ⇒ Boolean
Whether this failure encapsulate a Roby exception or a normal one.
-
#show_result?(result) ⇒ Boolean
Whether the reporter should show this result.
Instance Method Details
#aggregated_results(io) ⇒ Object
Overload of Minitest::SummaryReporter#aggregated_results
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/roby/test/minitest_reporter.rb', line 10 def aggregated_results(io) filtered_results = results.find_all { |result| show_result?(result) } filtered_results.each_with_index do |result, i| io.puts format("\n%<i>3d) %<result>s", i: i + 1, result: result_to_s(result)) end io.puts io end |
#failure_message(failure) ⇒ String
Generate a message for a test failure
46 47 48 49 50 51 52 |
# File 'lib/roby/test/minitest_reporter.rb', line 46 def (failure) return failure. unless roby_exception?(failure) io = StringIO.new Roby.display_exception(io, failure.error) io.string end |
#result_to_s(result) ⇒ String
Generate the string to display for a given test result
34 35 36 37 38 39 40 |
# File 'lib/roby/test/minitest_reporter.rb', line 34 def result_to_s(result) result.failures.map do |f| = (f) "#{f.result_label}:\n#{result.location}:\n#{message}" end.join("\n\n") end |
#roby_exception?(failure) ⇒ Boolean
Whether this failure encapsulate a Roby exception or a normal one
57 58 59 |
# File 'lib/roby/test/minitest_reporter.rb', line 57 def roby_exception?(failure) failure.respond_to?(:error) && failure.error.kind_of?(ExceptionBase) end |
#show_result?(result) ⇒ Boolean
Whether the reporter should show this result
24 25 26 27 28 |
# File 'lib/roby/test/minitest_reporter.rb', line 24 def show_result?(result) skip = [:skip] (!result.skipped? || [:verbose]) && (!skip || !skip.include?(result.result_code)) end |