Module: RubyUnit::Report
- Defined in:
- lib/RubyUnit/Report.rb
Overview
The RubyUnit::Report module is the test results report
Constant Summary collapse
- @@results =
[]
- @@fail =
[]
- @@skip =
[]
- @@incomplete =
[]
- @@errors =
[]
- @@start =
nil
- @@finish =
nil
- @@i =
0
- @@trace =
true
Class Method Summary collapse
- .counted_stats ⇒ Object
- .finish ⇒ Object
- .per_second(count) ⇒ Object
- .rated_stats ⇒ Object
- .record(result) ⇒ Object
- .report(type, results = [], trace = true) ⇒ Object
- .report_counted ⇒ Object
- .report_errors ⇒ Object
- .report_failures ⇒ Object
- .report_head(result) ⇒ Object
- .report_incompletes ⇒ Object
- .report_info(result, trace = true) ⇒ Object
- .report_rated ⇒ Object
- .report_skips ⇒ Object
- .report_stats ⇒ Object
- .report_timed ⇒ Object
- .start ⇒ Object
- .stats ⇒ Object
- .status ⇒ Object
- .tests ⇒ Object
- .timed_stats ⇒ Object
Class Method Details
.counted_stats ⇒ Object
136 137 138 139 140 141 142 |
# File 'lib/RubyUnit/Report.rb', line 136 def self.counted_stats counted = rated_stats.clone counted['Skipped Tests'] = @@skip.count unless @@skip.count.zero? counted['Incomplete Tests'] = @@incomplete.count unless @@incomplete.count.zero? counted['Failed Tests'] = @@fail.count counted end |
.finish ⇒ Object
46 47 48 49 |
# File 'lib/RubyUnit/Report.rb', line 46 def self.finish @@finish = Time.new if @@finish.nil? @@finish end |
.per_second(count) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/RubyUnit/Report.rb', line 92 def self.per_second count return 0 if @@start.nil? finish = @@finish.nil? ? Time.new : @@finish elapsed = (finish - @@start).to_r (count * (Rational(elapsed.denominator, elapsed.numerator))).to_f end |
.rated_stats ⇒ Object
120 121 122 123 124 125 |
# File 'lib/RubyUnit/Report.rb', line 120 def self.rated_stats rated = {} rated['Tests'] = tests rated['Assertions'] = TestCase.assertions rated end |
.record(result) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/RubyUnit/Report.rb', line 19 def self.record result @@results << result case result.error when RubyUnit::AssertionFailure @@fail << result when RubyUnit::SkippedTest @@skip << result when RubyUnit::IncompleteTest @@incomplete << result else if result.error.class <= Exception puts "error #{result.error.class}" @@errors << result end end end |
.report(type, results = [], trace = true) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/RubyUnit/Report.rb', line 63 def self.report type, results = [], trace = true @@i = 0 puts "\n#{results.count} #{type}:\n" if results.count > 0 results.each_with_index do |result, i| report_head result report_info result, trace end end |
.report_counted ⇒ Object
127 128 129 130 131 132 133 134 |
# File 'lib/RubyUnit/Report.rb', line 127 def self.report_counted s = '' counted_stats.each do |counted, count| s << "#{count} #{counted}" s << ', ' unless counted_stats.keys.last == counted end puts s end |
.report_errors ⇒ Object
72 73 74 |
# File 'lib/RubyUnit/Report.rb', line 72 def self.report_errors report 'Errors in Tests', @@errors end |
.report_failures ⇒ Object
76 77 78 |
# File 'lib/RubyUnit/Report.rb', line 76 def self.report_failures report 'Failed Tests', @@fail end |
.report_head(result) ⇒ Object
51 52 53 54 55 |
# File 'lib/RubyUnit/Report.rb', line 51 def self.report_head result puts puts "#{@@i += 1}) #{result.test_case}::#{result.test}(#{result.params})" puts result.error.class.to_s + ": " + result.error. end |
.report_incompletes ⇒ Object
84 85 86 |
# File 'lib/RubyUnit/Report.rb', line 84 def self.report_incompletes report 'Incomplete Tests', @@incomplete, false end |
.report_info(result, trace = true) ⇒ Object
57 58 59 60 61 |
# File 'lib/RubyUnit/Report.rb', line 57 def self.report_info result, trace = true puts puts result.error.info if result.error.respond_to? :info puts result.error.backtrace * "\n" if trace end |
.report_rated ⇒ Object
111 112 113 114 115 116 117 118 |
# File 'lib/RubyUnit/Report.rb', line 111 def self.report_rated s = '' rated_stats.each do |rated, count| s << "%.3f #{rated}/s" % [per_second(count)] s << ', ' unless rated_stats.keys.last == rated end puts s end |
.report_skips ⇒ Object
80 81 82 |
# File 'lib/RubyUnit/Report.rb', line 80 def self.report_skips report 'Skipped Tests', @@skip, false end |
.report_stats ⇒ Object
144 145 146 147 148 149 |
# File 'lib/RubyUnit/Report.rb', line 144 def self.report_stats puts report_timed report_rated report_counted end |
.report_timed ⇒ Object
99 100 101 102 103 |
# File 'lib/RubyUnit/Report.rb', line 99 def self.report_timed timed_stats.each do |key, duration| puts "#{key} in #{duration} seconds" end end |
.start ⇒ Object
41 42 43 44 |
# File 'lib/RubyUnit/Report.rb', line 41 def self.start @@start = Time.new if @@start.nil? @@start end |
.stats ⇒ Object
151 152 153 |
# File 'lib/RubyUnit/Report.rb', line 151 def self.stats {:timed=>timed_stats,:rate=>rated_stats,:count=>counted_stats} end |
.status ⇒ Object
88 89 90 |
# File 'lib/RubyUnit/Report.rb', line 88 def self.status @@fail.count + @@errors.count end |
.tests ⇒ Object
37 38 39 |
# File 'lib/RubyUnit/Report.rb', line 37 def self.tests @@results.count end |
.timed_stats ⇒ Object
105 106 107 108 109 |
# File 'lib/RubyUnit/Report.rb', line 105 def self.timed_stats timed = {} timed['Tests Completed'] = @@finish - @@start timed end |