Class: Results
- Inherits:
-
Object
- Object
- Results
- Defined in:
- lib/results.rb
Overview
A gloo unit test results collection. The results of a the set of tests run.
Instance Attribute Summary collapse
-
#assert_count ⇒ Object
Returns the value of attribute assert_count.
-
#fail_count ⇒ Object
Returns the value of attribute fail_count.
-
#file_count ⇒ Object
Returns the value of attribute file_count.
-
#pass_count ⇒ Object
Returns the value of attribute pass_count.
-
#test_count ⇒ Object
Returns the value of attribute test_count.
Instance Method Summary collapse
-
#add_result(result) ⇒ Object
Add a result to the collection.
-
#duration ⇒ Object
Get the duration of the test.
-
#end_timer ⇒ Object
End the timer.
-
#get_result_summary ⇒ Object
Get a textual summary of the results.
-
#initialize(engine) ⇒ Results
constructor
Set up the results collection.
-
#show_failures ⇒ Object
Show the failures.
-
#show_results ⇒ Object
Show the results.
-
#start_timer ⇒ Object
Set a timer to track test duration.
Constructor Details
#initialize(engine) ⇒ Results
Set up the results collection.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/results.rb', line 13 def initialize( engine ) @engine = engine @all_results = [] @failures = [] @file_count = 0 @pass_count = 0 @fail_count = 0 @assert_count = 0 @engine.log.debug "Results initialized" end |
Instance Attribute Details
#assert_count ⇒ Object
Returns the value of attribute assert_count.
7 8 9 |
# File 'lib/results.rb', line 7 def assert_count @assert_count end |
#fail_count ⇒ Object
Returns the value of attribute fail_count.
7 8 9 |
# File 'lib/results.rb', line 7 def fail_count @fail_count end |
#file_count ⇒ Object
Returns the value of attribute file_count.
7 8 9 |
# File 'lib/results.rb', line 7 def file_count @file_count end |
#pass_count ⇒ Object
Returns the value of attribute pass_count.
7 8 9 |
# File 'lib/results.rb', line 7 def pass_count @pass_count end |
#test_count ⇒ Object
Returns the value of attribute test_count.
7 8 9 |
# File 'lib/results.rb', line 7 def test_count @test_count end |
Instance Method Details
#add_result(result) ⇒ Object
Add a result to the collection.
60 61 62 63 64 65 66 67 68 |
# File 'lib/results.rb', line 60 def add_result( result ) @all_results << result @failures << result unless result.passed @pass_count += 1 if result.passed @fail_count += 1 unless result.passed @assert_count += result.assert_count @assert_count += result.refute_count end |
#duration ⇒ Object
Get the duration of the test.
48 49 50 |
# File 'lib/results.rb', line 48 def duration return @end_time - @start_time end |
#end_timer ⇒ Object
End the timer.
41 42 43 |
# File 'lib/results.rb', line 41 def end_timer @end_time = Time.now end |
#get_result_summary ⇒ Object
Get a textual summary of the results.
103 104 105 106 107 108 109 110 111 112 |
# File 'lib/results.rb', line 103 def get_result_summary str = "Tests: #{@all_results.length} • Passed: #{@pass_count} • ".white if @fail_count > 0 str += " Failed: #{@fail_count} ".red else str += " Failed: #{@fail_count} ".white end str += "\n Assertions: #{@assert_count} • Files: #{@file_count}".yellow return str end |
#show_failures ⇒ Object
Show the failures.
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/results.rb', line 89 def show_failures if @fail_count > 0 puts puts "*** Failures (#{@fail_count}) ***".red puts @failures.each do |failure| failure.show_failure end end end |
#show_results ⇒ Object
Show the results.
78 79 80 81 82 83 84 |
# File 'lib/results.rb', line 78 def show_results delta = duration.round( 2 ) puts puts get_result_summary puts "Tests finished in #{delta} seconds".white puts end |
#start_timer ⇒ Object
Set a timer to track test duration.
34 35 36 |
# File 'lib/results.rb', line 34 def start_timer @start_time = Time.now end |