One method of running one RSpec example concurrently multiple times to eliminate flakiness is using the "flaky" gem. The gem wraps the example with a retry block to rerun the test multiple times, with a specified number of attempts, using randomized seed.
To use the "flaky" gem, you can follow the steps below:
Install the gem by adding it to your Gemfile and running bundle install
.
gem 'flaky'
Add the flaky
tag to the RSpec example you want to run concurrently.
it "is a flaky example", flaky: 3 do
# Example code here
end
In this example, flaky: 3
means the example will be run three times.
Run your RSpec tests using the --tag flaky
option.
bundle exec rspec --tag flaky
This will run all RSpec examples with the flaky
tag concurrently multiple times as specified by the flaky
tag option.
Asked: 2023-06-11 08:36:08 +0000
Seen: 8 times
Last updated: Jun 11 '23