Class: Towel::Minitest::Reporter
- Inherits:
-
Minitest::AbstractReporter
- Object
- Minitest::AbstractReporter
- Towel::Minitest::Reporter
- Defined in:
- lib/towel/minitest/reporter.rb
Overview
Reports Minitest results to Towel.
Instance Method Summary collapse
-
#initialize(options) ⇒ Reporter
constructor
A new instance of Reporter.
- #prerecord(klass, name) ⇒ Object
- #record(result) ⇒ Object
- #report ⇒ Object
- #start ⇒ Object
Constructor Details
Instance Method Details
#prerecord(klass, name) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/towel/minitest/reporter.rb', line 35 def prerecord(klass, name) context = @session.create_result( klass.to_s, name, display_name: result_name(klass, name) ) @stdout.context = context @stderr.context = context end |
#record(result) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/towel/minitest/reporter.rb', line 46 def record(result) @stdout.context = nil @stderr.context = nil if result.passed? state = Towel::V1alpha::ResultState::SUCCESS elsif result.skipped? state = Towel::V1alpha::ResultState::SKIPPED elsif result.error? state = Towel::V1alpha::ResultState::ERROR else state = Towel::V1alpha::ResultState::FAILURE end duration = nil if !result.skipped? duration = result.time end description = nil if !result.failures.empty? description = result.failures.first. end @session.update_result( result.klass, result.name, state: state, duration: duration, description: description ) end |
#report ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/towel/minitest/reporter.rb', line 79 def report $stdout = @previous_stdout $stderr = @previous_stderr if @cancelled @session.cancel_invocation else @session.finish_invocation end end |
#start ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/towel/minitest/reporter.rb', line 14 def start url = @session.create_invocation puts "View test results at #{url}" # Register a cancellation handler old_handler = Signal.trap("INT") do @cancelled = true if old_handler.respond_to?(:call) old_handler.call else raise Interrupt end end # Capture logs @previous_stdout = $stdout $stdout = @stdout = Towel::LogIO.new(@session.create_log("STDOUT")) @previous_stderr = $stderr $stderr = @stderr = Towel::LogIO.new(@session.create_log("STDERR")) end |