123456789_123456789_123456789_123456789_123456789_

Class: Minitest::StatisticsReporter

Do not use. This class is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
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.

Class Method Summary

Instance Attribute Summary

Reporter - Inherited

#io

The IO used to report.

#options

Command-line options for this run.

AbstractReporter - Inherited

#passed?

Did this run pass?

Instance Method Summary

AbstractReporter - Inherited

#prerecord

About to start running a test.

#record

Record a result and output the Runnable#result_code.

#report

Outputs the summary of the run.

#start

Starts reporting on the run.

Constructor Details

.new(io = $stdout, options = {}) ⇒ StatisticsReporter

[ GitHub ]

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

def initialize io = $stdout, options = {} # :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)

[ GitHub ]

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

attr_accessor :assertions

#count (rw)

[ GitHub ]

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

attr_accessor :count

#errors (rw)

[ GitHub ]

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

attr_accessor :errors

#failures (rw)

[ GitHub ]

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

attr_accessor :failures

#passed?Boolean (readonly)

[ GitHub ]

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

def passed? # :nodoc:
  results.all?(&:skipped?)
end

#results (rw)

[ GitHub ]

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

attr_accessor :results

#skips (rw)

[ GitHub ]

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

attr_accessor :skips

#start_time (rw)

[ GitHub ]

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

attr_accessor :start_time

#total_time (rw)

[ GitHub ]

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

attr_accessor :total_time

Instance Method Details

#record(result)

[ GitHub ]

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

def record result # :nodoc:
  self.count += 1
  self.assertions += result.assertions

  results << result if not result.passed? or result.skipped?
end

#report

[ GitHub ]

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

def report # :nodoc:
  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

[ GitHub ]

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

def start # :nodoc:
  self.start_time = Minitest.clock_time
end