Class: Roby::Test::MinitestReporter

Inherits:
Minitest::SummaryReporter
  • Object
show all
Defined in:
lib/roby/test/minitest_reporter.rb

Overview

Minitest reporter aware of how exceptions should be displayed in Roby

Instance Method Summary collapse

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

Parameters:

  • failure (Minitest::Assertion)

Returns:

  • (String)


46
47
48
49
50
51
52
# File 'lib/roby/test/minitest_reporter.rb', line 46

def failure_message(failure)
    return failure.message 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

Parameters:

  • result (Minitest::Result)

Returns:

  • (String)


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|
        message = failure_message(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

Parameters:

  • f (Minitest::Assertion)

Returns:

  • (Boolean)


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

Parameters:

  • result (Minitest::Result)

Returns:

  • (Boolean)


24
25
26
27
28
# File 'lib/roby/test/minitest_reporter.rb', line 24

def show_result?(result)
    skip = options[:skip]
    (!result.skipped? || options[:verbose]) &&
        (!skip || !skip.include?(result.result_code))
end