Reputation: 6169
I have a suite of tests for a controller that makes calls to an external sandbox api for testing, which makes the performance rather slow. I'd like to improve performance by allowing parallel_tests to not only run suites in parallel, but individual describe
s.
For example:
RSpec.describe FooController do
describe '#index' ...
describe '#create' ...
end
Because the #index
and #create
tests do not share any memory space, it's fine to parallelize them. One option is:
RSpec.describe 'FooController#index' do
describe '#index' ...
end
RSpec.describe 'FooController#index' do
describe '#create' ...
end
but this makes the tests look awkward and a pain to read through. Is there a way I can easily have parallel_tests
run each describe
in parallel?
Upvotes: 1
Views: 475
Reputation: 6169
Turns out the maintainer of parallel_tests also has a gem designed just for this: https://github.com/grosser/parallel_split_test
After installing via gem install 'parallel_test_split'
you can simply run parallel_split_test
Reduced a slow (but small) suite from 12 seconds to 6
Upvotes: 4