Skip to content

Instantly share code, notes, and snippets.

@your
Created July 21, 2016 16:37
Show Gist options
  • Save your/9b807952d19f77242ac7caccd920c1cd to your computer and use it in GitHub Desktop.
Save your/9b807952d19f77242ac7caccd920c1cd to your computer and use it in GitHub Desktop.
RSpec tests bisection

To solve random tests failures, you can use the use the --bisect argument when running rspec.

A second argument --seed N is required to correctly bisect the tests.

Instructions

Take note of the seed number used in the latest failing test and run:

bundle exec rspec spec --seed SEED_NUMBER --bisect

Example result:

Bisect started using options: "spec --seed 29579"
Running suite to find failures... (10 minutes 33 seconds)
Starting bisect with 7 failing examples and 5515 non-failing examples.

Round 1: searching for 2758 non-failing examples (of 5515) to ignore: . (20 minutes 13 seconds)
Round 2: searching for 1379 non-failing examples (of 2757) to ignore: .. (2 minutes 1.6 seconds)
Round 3: searching for 690 non-failing examples (of 1379) to ignore: .. (1 minute 54.02 seconds)
Round 4: searching for 345 non-failing examples (of 690) to ignore: .. (1 minute 46.34 seconds)
Round 5: searching for 173 non-failing examples (of 345) to ignore: .. (36.88 seconds)
Round 6: searching for 87 non-failing examples (of 173) to ignore: . (19.06 seconds)
Round 7: searching for 43 non-failing examples (of 86) to ignore: . (12.83 seconds)
Round 8: searching for 22 non-failing examples (of 43) to ignore: .. (20.47 seconds)
Round 9: searching for 11 non-failing examples (of 22) to ignore: .. (19.01 seconds)
Round 10: searching for 6 non-failing examples (of 11) to ignore: . (10.48 seconds)
Round 11: searching for 3 non-failing examples (of 5) to ignore: . (9.97 seconds)
Round 12: searching for 1 non-failing example (of 2) to ignore: .. (17.72 seconds)
Round 13: searching for 1 non-failing example (of 1) to ignore: . (7.89 seconds)
Bisect complete! Reduced necessary non-failing examples from 5515 to 1 in 28 minutes 29 seconds.

The minimal reproduction command is:
  rspec ./spec/controllers/api/v1/appointments_controller_spec.rb[1:2:1:6,1:4:1:6,1:5:1:6] ./spec/features/admin/appointments_spec.rb[1:4] ./spec/features/admin/customers_spec.rb[1:1,1:2,1:5] ./spec/services/online_checkouts/create_service_spec.rb[1:3:2:4:1] --seed 29579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment