Class: MiniTest::ReporterRunner
- Inherits:
-
Unit
- Object
- Unit
- MiniTest::ReporterRunner
- Extended by:
- Forwardable
- Defined in:
- lib/minitest/reporter_runner.rb
Overview
Runner for MiniTest that supports reporters.
Based upon Ryan Davis of Seattle.rb's MiniTest (MIT License).
Instance Attribute Summary collapse
-
#reporters
Returns the value of attribute reporters.
-
#suite_start_time
readonly
Returns the value of attribute suite_start_time.
-
#suites_start_time
readonly
Returns the value of attribute suites_start_time.
-
#test_results
readonly
Returns the value of attribute test_results.
-
#test_start_time
readonly
Returns the value of attribute test_start_time.
Instance Method Summary collapse
- #_run_suite(suite, type)
- #_run_suites(suites, type)
- #after_test(suite, test)
- #before_test(suite, test)
-
#initialize ⇒ ReporterRunner
constructor
A new instance of ReporterRunner.
- #print(*args)
-
#puts(*args)
Stub out the three IO methods used by the built-in reporter.
- #record(suite, test, assertions, time, exception)
- #run_tests
- #status(io = output)
Constructor Details
#initialize ⇒ ReporterRunner
Returns a new instance of ReporterRunner.
20 21 22 23 24 25 26 |
# File 'lib/minitest/reporter_runner.rb', line 20 def initialize super self.reporters = [] @test_results = {} @test_recorder = TestRecorder.new @allow_default_output = true end |
Instance Attribute Details
#reporters
Returns the value of attribute reporters.
12 13 14 |
# File 'lib/minitest/reporter_runner.rb', line 12 def reporters @reporters end |
#suite_start_time (readonly)
Returns the value of attribute suite_start_time.
15 16 17 |
# File 'lib/minitest/reporter_runner.rb', line 15 def suite_start_time @suite_start_time end |
#suites_start_time (readonly)
Returns the value of attribute suites_start_time.
14 15 16 |
# File 'lib/minitest/reporter_runner.rb', line 14 def suites_start_time @suites_start_time end |
#test_results (readonly)
Returns the value of attribute test_results.
13 14 15 |
# File 'lib/minitest/reporter_runner.rb', line 13 def test_results @test_results end |
#test_start_time (readonly)
Returns the value of attribute test_start_time.
16 17 18 |
# File 'lib/minitest/reporter_runner.rb', line 16 def test_start_time @test_start_time end |
Instance Method Details
#_run_suite(suite, type)
42 43 44 45 46 47 48 |
# File 'lib/minitest/reporter_runner.rb', line 42 def _run_suite(suite, type) @suite_start_time = Time.now trigger_callback(:before_suite, suite) super(suite, type) ensure trigger_callback(:after_suite, suite) end |
#_run_suites(suites, type)
33 34 35 36 37 38 39 40 |
# File 'lib/minitest/reporter_runner.rb', line 33 def _run_suites(suites, type) @suites_start_time = Time.now count_tests!(suites, type) trigger_callback(:before_suites, suites, type) super(suites, type) ensure trigger_callback(:after_suites, suites, type) end |
#after_test(suite, test)
71 72 73 74 75 76 77 78 79 |
# File 'lib/minitest/reporter_runner.rb', line 71 def after_test(suite, test) runners = @test_recorder[suite, test.to_sym] runners.each do |runner| trigger_callback(runner.result, suite, test.to_sym, runner) end trigger_callback(:after_test, suite, test.to_sym) end |
#before_test(suite, test)
50 51 52 53 |
# File 'lib/minitest/reporter_runner.rb', line 50 def before_test(suite, test) @test_start_time = Time.now trigger_callback(:before_test, suite, test) end |
#print(*args)
86 87 88 |
# File 'lib/minitest/reporter_runner.rb', line 86 def print(*args) super if @allow_default_output end |
#puts(*args)
Stub out the three IO methods used by the built-in reporter.
82 83 84 |
# File 'lib/minitest/reporter_runner.rb', line 82 def puts(*args) super if @allow_default_output end |
#record(suite, test, assertions, time, exception)
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/minitest/reporter_runner.rb', line 55 def record(suite, test, assertions, time, exception) runner = TestRunner.new(suite, test.to_sym, assertions, time, exception) @test_results[suite] ||= {} @test_results[suite][test.to_sym] = runner @test_recorder.record(runner) # MiniTest < 4.1.0 sends #record after all teardown hooks, so explicitly # call #after_test here after recording. after_test(suite, test) if Unit::VERSION <= "4.1.0" end |
#run_tests
28 29 30 31 |
# File 'lib/minitest/reporter_runner.rb', line 28 def run_tests @allow_default_output = false super end |
#status(io = output)
90 91 92 |
# File 'lib/minitest/reporter_runner.rb', line 90 def status(io = output) super if @allow_default_output end |