Class: Minitest::SummaryReporter

Inherits:
StatisticsReporter show all
Defined in:
lib/minitest.rb

Overview

A reporter that prints the header, summary, and failure details at the end of the run.

This is added to the top-level CompositeReporter at the start of the run. If you want to change the output of minitest via a plugin, pull this out of the composite and replace it with your own.

Instance Attribute Summary collapse

Attributes inherited from StatisticsReporter

#assertions, #count, #errors, #failures, #results, #skips, #start_time, #total_time

Attributes inherited from Reporter

#io, #options

Instance Method Summary collapse

Methods inherited from StatisticsReporter

#initialize, #passed?, #record

Methods inherited from Reporter

#initialize

Methods inherited from AbstractReporter

#passed?, #prerecord, #record

Constructor Details

This class inherits a constructor from Minitest::StatisticsReporter

Instance Attribute Details

#old_syncObject

Returns the value of attribute old_sync.



753
754
755
# File 'lib/minitest.rb', line 753

def old_sync
  @old_sync
end

#syncObject

:stopdoc:



752
753
754
# File 'lib/minitest.rb', line 752

def sync
  @sync
end

Instance Method Details

#aggregated_results(io) ⇒ Object

:nodoc:



785
786
787
788
789
790
791
792
793
794
# File 'lib/minitest.rb', line 785

def aggregated_results io # :nodoc:
  filtered_results = results.dup
  filtered_results.reject!(&:skipped?) unless options[:verbose]

  filtered_results.each_with_index { |result, i|
    io.puts "\n%3d) %s" % [i+1, result]
  }
  io.puts
  io
end

#reportObject

:nodoc:



768
769
770
771
772
773
774
775
776
777
778
# File 'lib/minitest.rb', line 768

def report # :nodoc:
  super

  io.sync = self.old_sync

  io.puts unless options[:verbose] # finish the dots
  io.puts
  io.puts statistics
  aggregated_results io
  io.puts summary
end

#startObject

:startdoc:



756
757
758
759
760
761
762
763
764
765
766
# File 'lib/minitest.rb', line 756

def start # :nodoc:
  super

  io.puts "Run options: #{options[:args]}"
  io.puts
  io.puts "# Running:"
  io.puts

  self.sync = io.respond_to? :"sync=" # stupid emacs
  self.old_sync, io.sync = io.sync, true if self.sync
end

#statisticsObject

:nodoc:



780
781
782
783
# File 'lib/minitest.rb', line 780

def statistics # :nodoc:
  "Finished in %.6fs, %.4f runs/s, %.4f assertions/s." %
    [total_time, count / total_time, assertions / total_time]
end

#summaryObject

:nodoc:



800
801
802
803
804
805
806
807
808
# File 'lib/minitest.rb', line 800

def summary # :nodoc:
  extra = ""

  extra = "\n\nYou have skipped tests. Run with --verbose for details." if
    results.any?(&:skipped?) unless options[:verbose] or ENV["MT_NO_SKIP_MSG"]

  "%d runs, %d assertions, %d failures, %d errors, %d skips%s" %
    [count, assertions, failures, errors, skips, extra]
end

#to_sObject

:nodoc:



796
797
798
# File 'lib/minitest.rb', line 796

def to_s # :nodoc:
  aggregated_results(StringIO.new(binary_string)).string
end