Conversation
… RSpec json report with test examples
rake knapsack_pro:rspec_test_example_detector when no slow test files detected for RSpecrake knapsack_pro:rspec_test_example_detector when no slow test files are detected for RSpec
There was a problem hiding this comment.
Have you considered moving the logic specific to an adapter inside the adapter_class?
We could prolly replace most of fast_and_slow_test_files_to_run and its if adapter_class == KnapsackPro::Adapters::RSpecAdapter && KnapsackPro::Config::Env.rspec_split_by_test_examples? with something like:
adapter_class.new.some_name_that_makes_sense(args)
There was a problem hiding this comment.
Good idea. I extracted everything related to the RSpec to the adapter class. Other generic things stay in base allocator builder so that we have option to extend other adapters to also support test cases splitting in the future.
| # read the JSON report | ||
| detector = KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector.new | ||
| test_file_example_paths = detector.test_file_example_paths |
There was a problem hiding this comment.
| # read the JSON report | |
| detector = KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector.new | |
| test_file_example_paths = detector.test_file_example_paths | |
| KnapsackPro::TestCaseDetectors::RSpecTestExampleDetector | |
| .new | |
| .test_file_example_paths |
|
|
||
| context 'when rake task to detect RSpec test examples works' do | ||
| let(:slow_test_files) { double(size: 5) } | ||
| let(:slow_test_files) { double(size: 5, empty?: false) } |
There was a problem hiding this comment.
Is slow_test_files an array? If so, I'd pass a real thing rather than a stub.
There was a problem hiding this comment.
Ok. I use a real array now.
There was a problem hiding this comment.
Are we covering the empty?: true case?
| slow_test_files | ||
| end | ||
|
|
||
| def rspec_test_file_example_paths_for_slow_test_files(slow_test_files) |
There was a problem hiding this comment.
If you move this into the adapter, I guess you could do:
| def rspec_test_file_example_paths_for_slow_test_files(slow_test_files) | |
| def example_paths_for(test_files) |
…SpecAdapter class and keep the base allocator build generic so that we could add test cases splitting to new test runner adapters in the future
Performance improvement: don't run
rake knapsack_pro:rspec_test_example_detectorwhen no slow test files are detected for RSpec.Thanks to that, we improve performance and save a few or a dozen seconds (depending on the project's complexity).
Related issues
rake knapsack_pro:rspec_test_example_detectorneed to run if there aren't any slow specs? #223development testing
This PR change was tested with a bin script.