Class: FlakyTestTracker::Tracker
- Inherits:
-
Object
- Object
- FlakyTestTracker::Tracker
- Defined in:
- lib/flaky_test_tracker/tracker.rb
Overview
Test tracker.
Instance Attribute Summary collapse
-
#context ⇒ Object
The current value of context.
-
#pretend ⇒ Boolean
Run but do not make any changes on the #storage.
-
#reporter ⇒ #tracked_tests #resolved_tests
The current value of reporter.
-
#source ⇒ #file_source_location_uri #source_uri
The current value of source.
-
#storage ⇒ #all #create #update #delete
The current value of storage.
-
#test_input_factory ⇒ #build
The current value of test_input_factory.
-
#test_inputs_attributes ⇒ Array<Hash>
The current value of test_inputs_attributes.
-
#verbose ⇒ Boolean
The current value of verbose.
Instance Method Summary collapse
-
#add(reference:, description:, exception:, file_path:, line_number:, finished_at: Time.now) ⇒ Object
Add test attributes to the internal queue.
-
#clear ⇒ Object
Reset the internal queue.
-
#initialize(pretend:, storage:, context:, source:, reporter:, verbose:, test_input_factory: FlakyTestTracker::TestInputFactory.new) ⇒ Tracker
constructor
A new instance of Tracker.
- #tests ⇒ Array<Test>
-
#track ⇒ Array<Test>
For each test attributes in the internal queue.
Constructor Details
#initialize(pretend:, storage:, context:, source:, reporter:, verbose:, test_input_factory: FlakyTestTracker::TestInputFactory.new) ⇒ Tracker
Returns a new instance of Tracker.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/flaky_test_tracker/tracker.rb', line 18 def initialize( pretend:, storage:, context:, source:, reporter:, verbose:, test_input_factory: FlakyTestTracker::TestInputFactory.new ) @pretend = pretend @storage = storage @context = context @source = source @reporter = reporter @verbose = verbose @test_input_factory = test_input_factory @tests = nil @test_inputs_attributes = [] end |
Instance Attribute Details
#context ⇒ Object
Returns the current value of context.
15 16 17 |
# File 'lib/flaky_test_tracker/tracker.rb', line 15 def context @context end |
#pretend ⇒ Boolean
Run but do not make any changes on the #storage
15 16 17 |
# File 'lib/flaky_test_tracker/tracker.rb', line 15 def pretend @pretend end |
#reporter ⇒ #tracked_tests #resolved_tests
Returns the current value of reporter.
15 16 17 |
# File 'lib/flaky_test_tracker/tracker.rb', line 15 def reporter @reporter end |
#source ⇒ #file_source_location_uri #source_uri
Returns the current value of source.
15 16 17 |
# File 'lib/flaky_test_tracker/tracker.rb', line 15 def source @source end |
#storage ⇒ #all #create #update #delete
Returns the current value of storage.
15 16 17 |
# File 'lib/flaky_test_tracker/tracker.rb', line 15 def storage @storage end |
#test_input_factory ⇒ #build
Returns the current value of test_input_factory.
15 16 17 |
# File 'lib/flaky_test_tracker/tracker.rb', line 15 def test_input_factory @test_input_factory end |
#test_inputs_attributes ⇒ Array<Hash>
Returns the current value of test_inputs_attributes.
15 16 17 |
# File 'lib/flaky_test_tracker/tracker.rb', line 15 def test_inputs_attributes @test_inputs_attributes end |
#verbose ⇒ Boolean
Returns the current value of verbose.
15 16 17 |
# File 'lib/flaky_test_tracker/tracker.rb', line 15 def verbose @verbose end |
Instance Method Details
#add(reference:, description:, exception:, file_path:, line_number:, finished_at: Time.now) ⇒ Object
Add test attributes to the internal queue.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/flaky_test_tracker/tracker.rb', line 41 def add( reference:, description:, exception:, file_path:, line_number:, finished_at: Time.now ) @test_inputs_attributes << { reference: reference, description: description, exception: exception, file_path: file_path, line_number: line_number, finished_at: finished_at } end |
#clear ⇒ Object
Reset the internal queue.
81 82 83 84 |
# File 'lib/flaky_test_tracker/tracker.rb', line 81 def clear @tests = nil @test_inputs_attributes = [] end |
#tests ⇒ Array<Test>
All persisted FlakyTestTracker::Test on the #storage.
76 77 78 |
# File 'lib/flaky_test_tracker/tracker.rb', line 76 def tests @tests ||= @storage.all end |
#track ⇒ Array<Test>
For each test attributes in the internal queue.
- build FlakyTestTracker::TestInput
- resolve FlakyTestTracker::TestInput#source_location_url with #source
- increments FlakyTestTracker::TestInput#number_occurrences when FlakyTestTracker::Test with the same reference is found on the #storage
- persiste the FlakyTestTracker::TestInput on the storage
- report tracked_test with persisted FlakyTestTracker::Test Then report tracked_tests with all persisted FlakyTestTracker::Test
67 68 69 70 71 72 |
# File 'lib/flaky_test_tracker/tracker.rb', line 67 def track tracked_tests = test_inputs.map { |test_input| track_test(test_input) } reporter.tracked_tests(source: source, context: context, tests: tracked_tests) puts "\n[FlakyTestTracker][Tracker] #{tracked_tests.count} test(s) tracked" if verbose tracked_tests end |