123456789_123456789_123456789_123456789_123456789_

Class: Minitest::StatisticsReporter

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
self, 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

Instance Attribute Summary

AbstractReporter - Inherited

#passed?

Did this run pass?

Instance Method Summary

  • #report

    Report on the tracked statistics.

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.

Instance Attribute Details

#assertions (rw)

Total number of assertions.

[ GitHub ]

  
# File 'lib/minitest.rb', line 659

attr_accessor :assertions

#count (rw)

Total number of test cases.

[ GitHub ]

  
# File 'lib/minitest.rb', line 664

attr_accessor :count

#errors (rw)

Total number of tests that erred.

[ GitHub ]

  
# File 'lib/minitest.rb', line 692

attr_accessor :errors

#failures (rw)

Total number of tests that failed.

[ GitHub ]

  
# File 'lib/minitest.rb', line 687

attr_accessor :failures

#results (rw)

An Array of test cases that failed or were skipped.

[ GitHub ]

  
# File 'lib/minitest.rb', line 669

attr_accessor :results

#skips (rw)

Total number of tests that where skipped.

[ GitHub ]

  
# File 'lib/minitest.rb', line 697

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.

[ GitHub ]

  
# File 'lib/minitest.rb', line 676

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.

[ GitHub ]

  
# File 'lib/minitest.rb', line 682

attr_accessor :total_time

Instance Method Details

#report

Report on the tracked statistics.

[ GitHub ]

  
# File 'lib/minitest.rb', line 730

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