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 ,
Mutex_m
|
|
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
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. - #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. |
Constructor Details
.new(io = $stdout, options = {}) ⇒ StatisticsReporter
# File 'lib/minitest.rb', line 708
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 (rw)
Total number of assertions.
# File 'lib/minitest.rb', line 668
attr_accessor :assertions
#count (rw)
Total number of test cases.
# File 'lib/minitest.rb', line 673
attr_accessor :count
#errors (rw)
Total number of tests that erred.
# File 'lib/minitest.rb', line 701
attr_accessor :errors
#failures (rw)
Total number of tests that failed.
# File 'lib/minitest.rb', line 696
attr_accessor :failures
#passed? ⇒ Boolean
(readonly)
# File 'lib/minitest.rb', line 721
def passed? # :nodoc: results.all?(&:skipped?) end
#results (rw)
An Array
of test cases that failed or were skipped.
# File 'lib/minitest.rb', line 678
attr_accessor :results
#skips (rw)
Total number of tests that where skipped.
# File 'lib/minitest.rb', line 706
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 685
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 691
attr_accessor :total_time
Instance Method Details
#record(result)
# File 'lib/minitest.rb', line 729
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 739
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.skips = aggregate[Skip].size end
#start
# File 'lib/minitest.rb', line 725
def start # :nodoc: self.start_time = Minitest.clock_time end