Class: Betatest::StatisticsReporter
- Inherits:
-
Reporter
- Object
- AbstractReporter
- Reporter
- Betatest::StatisticsReporter
- Defined in:
- lib/betatest.rb
Overview
A reporter that gathers statistics about a test run. Does not do any IO because meant to be used as a parent class for a reporter that does.
If you want to create an entirely different type of output (eg, CI, HTML, etc), this is the place to start.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#assertions ⇒ Object
:stopdoc:.
-
#count ⇒ Object
Returns the value of attribute count.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#failures ⇒ Object
Returns the value of attribute failures.
-
#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.
Attributes inherited from Reporter
Instance Method Summary collapse
-
#initialize(io = $stdout, options = {}) ⇒ StatisticsReporter
constructor
:startdoc:.
-
#passed? ⇒ Boolean
:nodoc:.
-
#record(result) ⇒ Object
:nodoc:.
-
#report ⇒ Object
:nodoc:.
-
#start ⇒ Object
:nodoc:.
Constructor Details
#initialize(io = $stdout, options = {}) ⇒ StatisticsReporter
:startdoc:
481 482 483 484 485 486 487 488 489 490 491 492 |
# File 'lib/betatest.rb', line 481 def initialize io = $stdout, = {} # :nodoc: super self.assertions = 0 self.count = 0 self.results = [] self.start_time = nil self.total_time = nil self.failures = nil self.errors = nil self.skips = nil end |
Instance Attribute Details
#assertions ⇒ Object
:stopdoc:
471 472 473 |
# File 'lib/betatest.rb', line 471 def assertions @assertions end |
#count ⇒ Object
Returns the value of attribute count.
472 473 474 |
# File 'lib/betatest.rb', line 472 def count @count end |
#errors ⇒ Object
Returns the value of attribute errors.
477 478 479 |
# File 'lib/betatest.rb', line 477 def errors @errors end |
#failures ⇒ Object
Returns the value of attribute failures.
476 477 478 |
# File 'lib/betatest.rb', line 476 def failures @failures end |
#results ⇒ Object
Returns the value of attribute results.
473 474 475 |
# File 'lib/betatest.rb', line 473 def results @results end |
#skips ⇒ Object
Returns the value of attribute skips.
478 479 480 |
# File 'lib/betatest.rb', line 478 def skips @skips end |
#start_time ⇒ Object
Returns the value of attribute start_time.
474 475 476 |
# File 'lib/betatest.rb', line 474 def start_time @start_time end |
#total_time ⇒ Object
Returns the value of attribute total_time.
475 476 477 |
# File 'lib/betatest.rb', line 475 def total_time @total_time end |
Instance Method Details
#passed? ⇒ Boolean
:nodoc:
494 495 496 |
# File 'lib/betatest.rb', line 494 def passed? # :nodoc: results.all?(&:skipped?) end |
#record(result) ⇒ Object
:nodoc:
502 503 504 505 506 507 |
# File 'lib/betatest.rb', line 502 def record result # :nodoc: self.count += 1 self.assertions += result.assertions results << result if not result.passed? or result.skipped? end |
#report ⇒ Object
:nodoc:
509 510 511 512 513 514 515 516 517 |
# File 'lib/betatest.rb', line 509 def report # :nodoc: aggregate = results.group_by { |r| r.failure.class } aggregate.default = [] # dumb. group_by should provide this self.total_time = Time.now - start_time self.failures = aggregate[Assertion].size self.errors = aggregate[UnexpectedError].size self.skips = aggregate[Skip].size end |
#start ⇒ Object
:nodoc:
498 499 500 |
# File 'lib/betatest.rb', line 498 def start # :nodoc: self.start_time = Time.now end |