Class: Testcube::Tracker
- Inherits:
-
Object
- Object
- Testcube::Tracker
- Includes:
- Singleton
- Defined in:
- lib/testcube/tracker.rb
Instance Attribute Summary collapse
- #current_description ⇒ Object
- #current_exception ⇒ Object
- #current_line_number ⇒ Object
- #current_test_path ⇒ Object
-
#test_files_with_time ⇒ Object
readonly
Returns the value of attribute test_files_with_time.
Instance Method Summary collapse
-
#initialize ⇒ Tracker
constructor
A new instance of Tracker.
- #num_specs ⇒ Object
- #start_timer ⇒ Object
- #stop_timer ⇒ Object
- #total_time ⇒ Object
Constructor Details
#initialize ⇒ Tracker
10 11 12 |
# File 'lib/testcube/tracker.rb', line 10 def initialize set_defaults end |
Instance Attribute Details
#current_description ⇒ Object
41 42 43 44 |
# File 'lib/testcube/tracker.rb', line 41 def current_description raise("current_description needs to be set") unless @current_description @current_description end |
#current_exception ⇒ Object
46 47 48 49 |
# File 'lib/testcube/tracker.rb', line 46 def current_exception # can be nil @current_exception end |
#current_line_number ⇒ Object
36 37 38 39 |
# File 'lib/testcube/tracker.rb', line 36 def current_line_number raise("current_line_number needs to be set") unless @current_line_number @current_line_number end |
#current_test_path ⇒ Object
31 32 33 34 |
# File 'lib/testcube/tracker.rb', line 31 def current_test_path raise("current_test_path needs to be set") unless @current_test_path @current_test_path.sub(/^\.\//, '') end |
#test_files_with_time ⇒ Object (readonly)
Returns the value of attribute test_files_with_time.
7 8 9 |
# File 'lib/testcube/tracker.rb', line 7 def test_files_with_time @test_files_with_time end |
Instance Method Details
#num_specs ⇒ Object
55 56 57 |
# File 'lib/testcube/tracker.rb', line 55 def num_specs test_files_with_time.length end |
#start_timer ⇒ Object
14 15 16 |
# File 'lib/testcube/tracker.rb', line 14 def start_timer @start_time = now_without_mock_time.to_f end |
#stop_timer ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/testcube/tracker.rb', line 18 def stop_timer execution_time = @start_time ? now_without_mock_time.to_f - @start_time : 0.0 @test_files_with_time.push({ test_file: current_test_path, line_number: current_line_number, description: current_description, status: current_exception ? :fail : :pass, # TODO: we could have a better way to filter the backtrace backtrace: current_exception ? current_exception.backtrace.select { |s| s !~ /gems\/.*(rspec|bin)/ } : nil, execution_time: execution_time }) end |
#total_time ⇒ Object
51 52 53 |
# File 'lib/testcube/tracker.rb', line 51 def total_time test_files_with_time.map { |res| res[:execution_time] }.sum end |