Class: Minitest::StatisticsReporter
- Inherits:
-
Reporter
- Object
- AbstractReporter
- Reporter
- Minitest::StatisticsReporter
- 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
Direct Known Subclasses
Instance Attribute Summary collapse
-
#assertions ⇒ Object
Total number of assertions.
-
#count ⇒ Object
Total number of test cases.
-
#errors ⇒ Object
Total number of tests that erred.
-
#failures ⇒ Object
Total number of tests that failed.
-
#results ⇒ Object
An
Array
of test cases that failed or were skipped. -
#skips ⇒ Object
Total number of tests that where skipped.
-
#start_time ⇒ Object
Time the test run started.
-
#total_time ⇒ Object
Test run time.
-
#warnings ⇒ Object
Total number of tests that warned.
Attributes inherited from Reporter
Instance Method Summary collapse
-
#initialize(io = $stdout, options = {}) ⇒ StatisticsReporter
constructor
:nodoc:.
-
#passed? ⇒ Boolean
:nodoc:.
-
#record(result) ⇒ Object
:nodoc:.
-
#report ⇒ Object
Report on the tracked statistics.
-
#start ⇒ Object
:nodoc:.
Methods inherited from AbstractReporter
Constructor Details
#initialize(io = $stdout, options = {}) ⇒ StatisticsReporter
:nodoc:
844 845 846 847 848 849 850 851 852 853 854 855 856 |
# File 'lib/minitest.rb', line 844 def initialize io = $stdout, = {} # :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.warnings = nil self.skips = nil end |
Instance Attribute Details
#assertions ⇒ Object
Total number of assertions.
799 800 801 |
# File 'lib/minitest.rb', line 799 def assertions @assertions end |
#count ⇒ Object
Total number of test cases.
804 805 806 |
# File 'lib/minitest.rb', line 804 def count @count end |
#errors ⇒ Object
Total number of tests that erred.
832 833 834 |
# File 'lib/minitest.rb', line 832 def errors @errors end |
#failures ⇒ Object
Total number of tests that failed.
827 828 829 |
# File 'lib/minitest.rb', line 827 def failures @failures end |
#results ⇒ Object
An Array
of test cases that failed or were skipped.
809 810 811 |
# File 'lib/minitest.rb', line 809 def results @results end |
#skips ⇒ Object
Total number of tests that where skipped.
842 843 844 |
# File 'lib/minitest.rb', line 842 def skips @skips end |
#start_time ⇒ Object
Time the test run started. If available, the monotonic clock is used and this is a Float
, otherwise it’s an instance of Time
.
816 817 818 |
# File 'lib/minitest.rb', line 816 def start_time @start_time end |
#total_time ⇒ Object
Test run time. If available, the monotonic clock is used and this is a Float
, otherwise it’s an instance of Time
.
822 823 824 |
# File 'lib/minitest.rb', line 822 def total_time @total_time end |
#warnings ⇒ Object
Total number of tests that warned.
837 838 839 |
# File 'lib/minitest.rb', line 837 def warnings @warnings end |
Instance Method Details
#passed? ⇒ Boolean
:nodoc:
858 859 860 |
# File 'lib/minitest.rb', line 858 def passed? # :nodoc: results.all?(&:skipped?) end |
#record(result) ⇒ Object
:nodoc:
866 867 868 869 870 871 |
# File 'lib/minitest.rb', line 866 def record result # :nodoc: self.count += 1 self.assertions += result.assertions results << result if not result.passed? or result.skipped? end |
#report ⇒ Object
Report on the tracked statistics.
876 877 878 879 880 881 882 883 884 885 |
# File 'lib/minitest.rb', line 876 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.warnings = aggregate[UnexpectedWarning].size self.skips = aggregate[Skip].size end |
#start ⇒ Object
:nodoc:
862 863 864 |
# File 'lib/minitest.rb', line 862 def start # :nodoc: self.start_time = Minitest.clock_time end |