Class: Minitest::StatisticsReporter
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
Reporter ,
AbstractReporter
|
|
Instance Chain:
self,
Reporter ,
AbstractReporter
|
|
Inherits: |
Minitest::Reporter
|
Defined in: | lib/minitest.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.
Example:
class JenkinsCIReporter < StatisticsReporter
def report
super # Needed to calculate some statistics
print "<testsuite "
print "tests='#{count}' "
print "failures='#{failures}' "
# Remaining XML...
end
end
Class Method Summary
- .new(io = $stdout, options = {}) ⇒ StatisticsReporter constructor Internal use only
Reporter
- Inherited
AbstractReporter
- Inherited
Instance Attribute Summary
-
#assertions
rw
Total number of assertions.
-
#count
rw
Total number of test cases.
-
#errors
rw
Total number of tests that erred.
-
#failures
rw
Total number of tests that failed.
-
#results
rw
An
Array
of test cases that failed or were skipped. -
#skips
rw
Total number of tests that where skipped.
-
#start_time
rw
Time the test run started.
-
#total_time
rw
Test
run time. -
#warnings
rw
Total number of tests that warned.
- #passed? ⇒ Boolean readonly Internal use only
Reporter
- Inherited
AbstractReporter
- Inherited
#passed? | Did this run pass? |
Instance Method Summary
-
#report
Report on the tracked statistics.
- #record(result) Internal use only
- #start Internal use only
AbstractReporter
- Inherited
#prerecord | About to start running a test. |
#record | Output and record the result of the test. |
#report | Outputs the summary of the run. |
#start | Starts reporting on the run. |
#synchronize |
Constructor Details
.new(io = $stdout, options = {}) ⇒ StatisticsReporter
# File 'lib/minitest.rb', line 843
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.warnings = nil self.skips = nil end
Instance Attribute Details
#assertions (rw)
Total number of assertions.
# File 'lib/minitest.rb', line 798
attr_accessor :assertions
#count (rw)
Total number of test cases.
# File 'lib/minitest.rb', line 803
attr_accessor :count
#errors (rw)
Total number of tests that erred.
# File 'lib/minitest.rb', line 831
attr_accessor :errors
#failures (rw)
Total number of tests that failed.
# File 'lib/minitest.rb', line 826
attr_accessor :failures
#passed? ⇒ Boolean
(readonly)
# File 'lib/minitest.rb', line 857
def passed? # :nodoc: results.all?(&:skipped?) end
#results (rw)
An Array
of test cases that failed or were skipped.
# File 'lib/minitest.rb', line 808
attr_accessor :results
#skips (rw)
Total number of tests that where skipped.
# File 'lib/minitest.rb', line 841
attr_accessor :skips
#start_time (rw)
Time the test run started. If available, the monotonic clock is used and this is a Float
, otherwise it’s an instance of Time
.
# File 'lib/minitest.rb', line 815
attr_accessor :start_time
#total_time (rw)
Test
run time. If available, the monotonic clock is used and this is a Float
, otherwise it’s an instance of Time
.
# File 'lib/minitest.rb', line 821
attr_accessor :total_time
#warnings (rw)
Total number of tests that warned.
# File 'lib/minitest.rb', line 836
attr_accessor :warnings
Instance Method Details
#record(result)
# File 'lib/minitest.rb', line 865
def record result # :nodoc: self.count += 1 self.assertions += result.assertions results << result if not result.passed? or result.skipped? end
#report
Report on the tracked statistics.
# File 'lib/minitest.rb', line 875
def report aggregate = results.group_by { |r| r.failure.class } aggregate.default = [] # dumb. group_by should provide this self.total_time = Minitest.clock_time - start_time self.failures = aggregate[Assertion].size self.errors = aggregate[UnexpectedError].size self.warnings = aggregate[UnexpectedWarning].size self.skips = aggregate[Skip].size end
#start
# File 'lib/minitest.rb', line 861
def start # :nodoc: self.start_time = Minitest.clock_time end