Class: Minitest::StatisticsReporter
- Inherits:
-
Reporter
- Object
- AbstractReporter
- Reporter
- Minitest::StatisticsReporter
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/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.
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:
723 724 725 726 727 728 729 730 731 732 733 734 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest.rb', line 723 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.skips = nil end |
Instance Attribute Details
#assertions ⇒ Object
Total number of assertions.
683 684 685 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest.rb', line 683 def assertions @assertions end |
#count ⇒ Object
Total number of test cases.
688 689 690 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest.rb', line 688 def count @count end |
#errors ⇒ Object
Total number of tests that erred.
716 717 718 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest.rb', line 716 def errors @errors end |
#failures ⇒ Object
Total number of tests that failed.
711 712 713 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest.rb', line 711 def failures @failures end |
#results ⇒ Object
An Array
of test cases that failed or were skipped.
693 694 695 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest.rb', line 693 def results @results end |
#skips ⇒ Object
Total number of tests that where skipped.
721 722 723 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest.rb', line 721 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
.
700 701 702 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest.rb', line 700 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
.
706 707 708 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest.rb', line 706 def total_time @total_time end |
Instance Method Details
#passed? ⇒ Boolean
:nodoc:
736 737 738 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest.rb', line 736 def passed? # :nodoc: results.all?(&:skipped?) end |
#record(result) ⇒ Object
:nodoc:
744 745 746 747 748 749 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest.rb', line 744 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.
754 755 756 757 758 759 760 761 762 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest.rb', line 754 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.skips = aggregate[Skip].size end |
#start ⇒ Object
:nodoc:
740 741 742 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/minitest-5.17.0/lib/minitest.rb', line 740 def start # :nodoc: self.start_time = Minitest.clock_time end |