Sha256: 5a5c3785a02c8c09549e06147cf498780c5029465a7dcc3f188b5cf39a3cc2b6
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
require 'json' module Minitest module FailureReporter class Reporter def initialize(io, options) @io = io @results = [] @options = options end def passed? true end def start; end def record(result) if has_failures?(result) @results << result end end def report failures = @results.map { |test| format(test) }.to_json @io.puts(failures) end def format(test) test_file, test_line = test.source_location { test_file: test_file, test_line: test_line, test_and_module_name: "#{test.klass}##{test.name}", test_name: test.name, test_suite: test.klass, error_class: test.failure.exception.class.name, error_message: full_error_message(test), output: full_error_message(test), } end private def has_failures?(test) !test.failures.empty? || test.error? end def full_error_message(test) [message(test), *backtrace(test)].join("\n") end def message(test) error = test.failure if error.is_a?(UnexpectedError) "#{error.exception.class}: #{error.exception.message}" else error.exception.message end end def backtrace(test) test.failure.backtrace.join("\n") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
minitest-failure-reporter-0.1.0 | lib/minitest/failure_reporter_reporter.rb |