Class: Minitest::StatisticsReporter

Inherits:
Reporter show all
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.

Direct Known Subclasses

SummaryReporter

Instance Attribute Summary collapse

Attributes inherited from Reporter

#io, #options

Instance Method Summary collapse

Methods inherited from AbstractReporter

#prerecord

Constructor Details

#initialize(io = $stdout, options = {}) ⇒ StatisticsReporter

:startdoc:



522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/minitest.rb', line 522

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

#assertionsObject

:stopdoc:



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

def assertions
  @assertions
end

#countObject

Returns the value of attribute count.



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

def count
  @count
end

#errorsObject

Returns the value of attribute errors.



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

def errors
  @errors
end

#failuresObject

Returns the value of attribute failures.



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

def failures
  @failures
end

#resultsObject

Returns the value of attribute results.



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

def results
  @results
end

#skipsObject

Returns the value of attribute skips.



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

def skips
  @skips
end

#start_timeObject

Returns the value of attribute start_time.



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

def start_time
  @start_time
end

#total_timeObject

Returns the value of attribute total_time.



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

def total_time
  @total_time
end

Instance Method Details

#passed?Boolean

:nodoc:

Returns:

  • (Boolean)


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

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

#record(result) ⇒ Object

:nodoc:



543
544
545
546
547
548
# File 'lib/minitest.rb', line 543

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

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

#reportObject

:nodoc:



550
551
552
553
554
555
556
557
558
# File 'lib/minitest.rb', line 550

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

#startObject

:nodoc:



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

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