Class: Testcube::Tracker
- Inherits:
-
Object
- Object
- Testcube::Tracker
- Includes:
- Singleton
- Defined in:
- lib/testcube/tracker.rb
Instance Attribute Summary collapse
- #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
Returns a new instance of Tracker.
10 11 12 |
# File 'lib/testcube/tracker.rb', line 10 def initialize set_defaults end |
Instance Attribute Details
#current_exception ⇒ Object
40 41 42 43 |
# File 'lib/testcube/tracker.rb', line 40 def current_exception # can be nil @current_exception end |
#current_line_number ⇒ Object
35 36 37 38 |
# File 'lib/testcube/tracker.rb', line 35 def current_line_number raise("current_line_number needs to be set") unless @current_line_number @current_line_number end |
#current_test_path ⇒ Object
30 31 32 33 |
# File 'lib/testcube/tracker.rb', line 30 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
49 50 51 |
# File 'lib/testcube/tracker.rb', line 49 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 |
# 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, 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
45 46 47 |
# File 'lib/testcube/tracker.rb', line 45 def total_time test_files_with_time.map { |res| res[:execution_time] }.sum end |