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
Class Method Summary collapse
- .errors ⇒ Object
- .failures ⇒ Object
- .finish ⇒ Object
- .incompletes ⇒ Object
- .record(result) ⇒ Object
- .report(type, results = [], trace = true) ⇒ Object
- .skips ⇒ Object
- .start ⇒ Object
- .stats ⇒ Object
- .status ⇒ Object
- .tests ⇒ Object
Class Method Details
.errors ⇒ Object
58 59 60 |
# File 'lib/RubyUnit/Report.rb', line 58 def self.errors report 'Errors in Tests', @@errors end |
.failures ⇒ Object
62 63 64 |
# File 'lib/RubyUnit/Report.rb', line 62 def self.failures report 'Failed Tests', @@fail end |
.finish ⇒ Object
44 45 46 47 |
# File 'lib/RubyUnit/Report.rb', line 44 def self.finish @@finish = Time.new if @@finish.nil? @@finish end |
.incompletes ⇒ Object
70 71 72 |
# File 'lib/RubyUnit/Report.rb', line 70 def self.incompletes report 'Incomplete Tests', @@incomplete, false end |
.record(result) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/RubyUnit/Report.rb', line 17 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
49 50 51 52 53 54 55 56 |
# File 'lib/RubyUnit/Report.rb', line 49 def self.report type, results = [], trace = true puts "\n#{results.count} #{type}:\n" if results.count > 0 results.each_with_index do |result, i| puts "\n#{i + 1}) #{result.test_case}::#{result.test}(#{result.params})" puts "#{result.error.class}: #{result.error.message}" puts result.error.backtrace * "\n" if trace end end |
.skips ⇒ Object
66 67 68 |
# File 'lib/RubyUnit/Report.rb', line 66 def self.skips report 'Skipped Tests', @@skip, false end |
.start ⇒ Object
39 40 41 42 |
# File 'lib/RubyUnit/Report.rb', line 39 def self.start @@start = Time.new if @@start.nil? @@start end |
.stats ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/RubyUnit/Report.rb', line 78 def self.stats elapsed = @@finish - @@start inverse = Rational(elapsed.to_r.denominator,elapsed.to_r.numerator) puts puts "Tests Complete in #{elapsed} seconds!" puts "%.3f tests/s, %.3f assertions/s" % [(tests * inverse).to_f, (TestCase.assertions * inverse).to_f] puts "%d Assertions, %d Skipped Tests, %d Incomplete Tests" % [TestCase.assertions, @@skip.count, @@incomplete.count] puts "%d Tests, %d Errors, %d Failures" % [tests, @@errors.count, @@fail.count] puts end |
.status ⇒ Object
74 75 76 |
# File 'lib/RubyUnit/Report.rb', line 74 def self.status @@fail.count + @@errors.count end |
.tests ⇒ Object
35 36 37 |
# File 'lib/RubyUnit/Report.rb', line 35 def self.tests @@results.count end |