How to stop running tests on the first failed test (fail fast tests in RSpec)?
If you want to stop running tests as soon as one of it fails then you can pass --fail-fast RSpec option to knapsack_pro
:
# Regular Mode
bundle exec rake "knapsack_pro:rspec[--fail-fast]"
# Queue Mode
bundle exec rake "knapsack_pro:queue:rspec[--fail-fast]"
You may add a parameter to tell RSpec to stop running the test suite after N failed tests, for example: --fail-fast=3
.
Note there is no =
char on purpose here:
# Regular Mode
bundle exec rake "knapsack_pro:rspec[--fail-fast 3]"
# Queue Mode
bundle exec rake "knapsack_pro:queue:rspec[--fail-fast 3]"
There is a downside to it. If you stop running tests then tests that were never run will have no recorded timing of execution and because of that, the future CI build might have tests split across CI nodes in no optimal way.