Class: Test::Recorder
- Inherits:
-
Object
- Object
- Test::Recorder
- Defined in:
- lib/rubytest/recorder.rb
Overview
Owns run results and controls when they reach the reporter.
Instance Attribute Summary collapse
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
Instance Method Summary collapse
- #begin_case(test_case) ⇒ Object
- #begin_suite(suite) ⇒ Object
- #begin_test(test) ⇒ Object
- #capture_output? ⇒ Boolean
- #end_case(test_case) ⇒ Object
- #end_suite(suite) ⇒ Object
- #end_test(test) ⇒ Object
-
#initialize(reporter = nil) ⇒ Recorder
constructor
A new instance of Recorder.
- #record(result) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(reporter = nil) ⇒ Recorder
Returns a new instance of Recorder.
6 7 8 9 |
# File 'lib/rubytest/recorder.rb', line 6 def initialize(reporter = nil) @reporter = reporter @results = [] end |
Instance Attribute Details
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
4 5 6 |
# File 'lib/rubytest/recorder.rb', line 4 def reporter @reporter end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
4 5 6 |
# File 'lib/rubytest/recorder.rb', line 4 def results @results end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
4 5 6 |
# File 'lib/rubytest/recorder.rb', line 4 def summary @summary end |
Instance Method Details
#begin_case(test_case) ⇒ Object
17 18 19 |
# File 'lib/rubytest/recorder.rb', line 17 def begin_case(test_case) reporter.begin_case(test_case) if reporter&.respond_to?(:begin_case) end |
#begin_suite(suite) ⇒ Object
11 12 13 14 15 |
# File 'lib/rubytest/recorder.rb', line 11 def begin_suite(suite) @suite = suite @started_at = Process.clock_gettime(Process::CLOCK_MONOTONIC) reporter.begin_suite(suite) if reporter&.respond_to?(:begin_suite) end |
#begin_test(test) ⇒ Object
21 22 23 |
# File 'lib/rubytest/recorder.rb', line 21 def begin_test(test) reporter.begin_test(test) if reporter&.respond_to?(:begin_test) end |
#capture_output? ⇒ Boolean
25 26 27 |
# File 'lib/rubytest/recorder.rb', line 25 def capture_output? !!(reporter && reporter.respond_to?(:capture_output?) && reporter.capture_output?) end |
#end_case(test_case) ⇒ Object
39 40 41 |
# File 'lib/rubytest/recorder.rb', line 39 def end_case(test_case) reporter.end_case(test_case) if reporter&.respond_to?(:end_case) end |
#end_suite(suite) ⇒ Object
43 44 45 46 47 |
# File 'lib/rubytest/recorder.rb', line 43 def end_suite(suite) @summary = RunSummary.new(suite: suite, results: results, elapsed: elapsed) reporter.finish(@summary) if reporter @summary end |
#end_test(test) ⇒ Object
35 36 37 |
# File 'lib/rubytest/recorder.rb', line 35 def end_test(test) reporter.end_test(test) if reporter&.respond_to?(:end_test) end |
#record(result) ⇒ Object
29 30 31 32 33 |
# File 'lib/rubytest/recorder.rb', line 29 def record(result) @results << result reporter.record(result) if reporter result end |
#success? ⇒ Boolean
49 50 51 |
# File 'lib/rubytest/recorder.rb', line 49 def success? (@summary || RunSummary.new(suite: @suite, results: results, elapsed: elapsed)).success? end |