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 Reporter

#simple_record, synchronize

Constructor Details

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

:startdoc:



570
571
572
573
574
575
576
577
578
579
580
581
# File 'lib/minitest.rb', line 570

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:



560
561
562
# File 'lib/minitest.rb', line 560

def assertions
  @assertions
end

#countObject

Returns the value of attribute count.



561
562
563
# File 'lib/minitest.rb', line 561

def count
  @count
end

#errorsObject

Returns the value of attribute errors.



566
567
568
# File 'lib/minitest.rb', line 566

def errors
  @errors
end

#failuresObject

Returns the value of attribute failures.



565
566
567
# File 'lib/minitest.rb', line 565

def failures
  @failures
end

#resultsObject

Returns the value of attribute results.



562
563
564
# File 'lib/minitest.rb', line 562

def results
  @results
end

#skipsObject

Returns the value of attribute skips.



567
568
569
# File 'lib/minitest.rb', line 567

def skips
  @skips
end

#start_timeObject

Returns the value of attribute start_time.



563
564
565
# File 'lib/minitest.rb', line 563

def start_time
  @start_time
end

#total_timeObject

Returns the value of attribute total_time.



564
565
566
# File 'lib/minitest.rb', line 564

def total_time
  @total_time
end

Instance Method Details

#passed?Boolean

:nodoc:

Returns:

  • (Boolean)


583
584
585
# File 'lib/minitest.rb', line 583

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

#record(result) ⇒ Object

:nodoc:



591
592
593
594
595
596
# File 'lib/minitest.rb', line 591

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

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

#reportObject

:nodoc:



598
599
600
601
602
603
604
605
606
# File 'lib/minitest.rb', line 598

def report # :nodoc:
  aggregate = results.group_by { |r| r.failure.class }
  aggregate.default = [] # dumb. group_by should provide this

  self.total_time = Time.now - start_time
  self.failures   = aggregate[Assertion].size
  self.errors     = aggregate[UnexpectedError].size
  self.skips      = aggregate[Skip].size
end

#startObject

:nodoc:



587
588
589
# File 'lib/minitest.rb', line 587

def start # :nodoc:
  self.start_time = Time.now
end