Class: Tunit::Reporter
- Inherits:
-
Object
- Object
- Tunit::Reporter
- Defined in:
- lib/tunit/reporter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#assertions ⇒ Object
Returns the value of attribute assertions.
-
#count ⇒ Object
Returns the value of attribute count.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#failures ⇒ Object
Returns the value of attribute failures.
-
#io ⇒ Object
Returns the value of attribute io.
-
#options ⇒ Object
Returns the value of attribute options.
-
#results ⇒ Object
Returns the value of attribute results.
-
#skips ⇒ Object
Returns the value of attribute skips.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#total_time ⇒ Object
Returns the value of attribute total_time.
Instance Method Summary collapse
-
#initialize(io = $stdout, options = {}) ⇒ Reporter
constructor
A new instance of Reporter.
- #passed? ⇒ Boolean
- #record(result) ⇒ Object
- #report ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(io = $stdout, options = {}) ⇒ Reporter
Returns a new instance of Reporter.
3 4 5 6 7 8 9 |
# File 'lib/tunit/reporter.rb', line 3 def initialize io = $stdout, = {} self.io = io self. = self.assertions = 0 self.count = 0 self.results = [] end |
Instance Attribute Details
#assertions ⇒ Object
Returns the value of attribute assertions.
10 11 12 |
# File 'lib/tunit/reporter.rb', line 10 def assertions @assertions end |
#count ⇒ Object
Returns the value of attribute count.
10 11 12 |
# File 'lib/tunit/reporter.rb', line 10 def count @count end |
#errors ⇒ Object
Returns the value of attribute errors.
12 13 14 |
# File 'lib/tunit/reporter.rb', line 12 def errors @errors end |
#failures ⇒ Object
Returns the value of attribute failures.
12 13 14 |
# File 'lib/tunit/reporter.rb', line 12 def failures @failures end |
#io ⇒ Object
Returns the value of attribute io.
10 11 12 |
# File 'lib/tunit/reporter.rb', line 10 def io @io end |
#options ⇒ Object
Returns the value of attribute options.
10 11 12 |
# File 'lib/tunit/reporter.rb', line 10 def @options end |
#results ⇒ Object
Returns the value of attribute results.
10 11 12 |
# File 'lib/tunit/reporter.rb', line 10 def results @results end |
#skips ⇒ Object
Returns the value of attribute skips.
12 13 14 |
# File 'lib/tunit/reporter.rb', line 12 def skips @skips end |
#start_time ⇒ Object
Returns the value of attribute start_time.
11 12 13 |
# File 'lib/tunit/reporter.rb', line 11 def start_time @start_time end |
#total_time ⇒ Object
Returns the value of attribute total_time.
11 12 13 |
# File 'lib/tunit/reporter.rb', line 11 def total_time @total_time end |
Instance Method Details
#passed? ⇒ Boolean
25 26 27 |
# File 'lib/tunit/reporter.rb', line 25 def passed? results.all?(&:skipped?) end |
#record(result) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/tunit/reporter.rb', line 18 def record result self.count += 1 self.assertions += result.assertions self.results << result if !result.passed? || result.skipped? end |
#report ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/tunit/reporter.rb', line 29 def report total = results.group_by {|r| r.failure.class } total.default = [] self.total_time = Time.now - start_time self.failures = total[Assertion].size self.failures += total[Empty].size self.skips = total[Skip].size end |
#start ⇒ Object
14 15 16 |
# File 'lib/tunit/reporter.rb', line 14 def start self.start_time = Time.now end |