class Minitest::Reporters::BaseReporter
Attributes
tests[RW]
Public Class Methods
new(options = {})
click to toggle source
Calls superclass method
# File lib/minitest/reporters/base_reporter.rb, line 28 def initialize(options = {}) super($stdout, options) self.tests = [] end
Public Instance Methods
add_defaults(defaults)
click to toggle source
# File lib/minitest/reporters/base_reporter.rb, line 33 def add_defaults(defaults) self.options = defaults.merge(options) end
after_test(_test)
click to toggle source
called by our own after hooks
# File lib/minitest/reporters/base_reporter.rb, line 55 def after_test(_test); end
before_test(test)
click to toggle source
called by our own before hooks
# File lib/minitest/reporters/base_reporter.rb, line 38 def before_test(test) last_test = test_class(tests.last) suite_changed = last_test.nil? || last_test.name != test.class.name return unless suite_changed after_suite(last_test) if last_test before_suite(test_class(test)) end
record(test)
click to toggle source
Calls superclass method
# File lib/minitest/reporters/base_reporter.rb, line 49 def record(test) super tests << test end
report()
click to toggle source
Calls superclass method
# File lib/minitest/reporters/base_reporter.rb, line 57 def report super if last_suite = test_class(tests.last) after_suite(last_suite) end end
Protected Instance Methods
after_suite(test)
click to toggle source
# File lib/minitest/reporters/base_reporter.rb, line 66 def after_suite(test); end
before_suite(test)
click to toggle source
# File lib/minitest/reporters/base_reporter.rb, line 68 def before_suite(test); end
filter_backtrace(backtrace)
click to toggle source
# File lib/minitest/reporters/base_reporter.rb, line 111 def filter_backtrace(backtrace) Minitest.filter_backtrace(backtrace) end
print(*args)
click to toggle source
# File lib/minitest/reporters/base_reporter.rb, line 119 def print(*args) io.print(*args) end
print_colored_status(test)
click to toggle source
# File lib/minitest/reporters/base_reporter.rb, line 93 def print_colored_status(test) if test.passed? print(green { pad_mark(result(test).to_s.upcase) }) elsif test.skipped? print(yellow { pad_mark(result(test).to_s.upcase) }) else print(red { pad_mark(result(test).to_s.upcase) }) end end
print_info(e, name = true)
click to toggle source
# File lib/minitest/reporters/base_reporter.rb, line 123 def print_info(e, name = true) print "#{e.exception.class}: " if name e.message.each_line { |line| print_with_info_padding(line) } # When e is a Minitest::UnexpectedError, the filtered backtrace is already part of the message printed out # by the previous line. In that case, and that case only, skip the backtrace output. return if e.is_a?(MiniTest::UnexpectedError) trace = filter_backtrace(e.backtrace) trace.each { |line| print_with_info_padding(line) } end
puts(*args)
click to toggle source
# File lib/minitest/reporters/base_reporter.rb, line 115 def puts(*args) io.puts(*args) end
result(test)
click to toggle source
# File lib/minitest/reporters/base_reporter.rb, line 70 def result(test) if test.error? :error elsif test.skipped? :skip elsif test.failure :fail else :pass end end
test_class(result)
click to toggle source
# File lib/minitest/reporters/base_reporter.rb, line 82 def test_class(result) # Minitest broke API between 5.10 and 5.11 this gets around Result object if result.nil? nil elsif result.respond_to? :klass Suite.new(result.klass) else Suite.new(result.class.name) end end
total_count()
click to toggle source
# File lib/minitest/reporters/base_reporter.rb, line 107 def total_count options[:total_count] end
total_time()
click to toggle source
Calls superclass method
# File lib/minitest/reporters/base_reporter.rb, line 103 def total_time super || Minitest::Reporters.clock_time - start_time end