Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure rspec to run specs in random order #59

Closed
2 tasks
MothOnMars opened this issue May 16, 2018 · 0 comments
Closed
2 tasks

configure rspec to run specs in random order #59

MothOnMars opened this issue May 16, 2018 · 0 comments
Assignees
Labels

Comments

@MothOnMars
Copy link
Contributor

MothOnMars commented May 16, 2018

Currently, our specs run in the same order each time, which can result in unexpected failures when tests are run out of order. This prevents us from running our tests in parallel (#55), and generally slows down development when unexpected errors occur.

This behavior can be see by running rspec spec/ --order rand.

The default spec_helper.rb file includes information on configuring random ordering:

  # Run specs in random order to surface order dependencies. If you find an
  # order dependency and want to debug it, you can fix the order by providing
  # the seed, which is printed after each run.
  #     --seed 1234
  config.order = :random

  # Seed global randomization in this process using the `--seed` CLI option.
  # Setting this allows you to use `--seed` to deterministically reproduce
  # test failures related to randomization by passing the same `--seed` value
  # as the one that triggered the failure.
  Kernel.srand config.seed

We should:

  • add those configuration options & notes to our spec_helper.rb to ensure specs are run in random order
  • fix any specs that are order-dependent

(Note: One reason I've found for some order-dependency is fixtures that are loaded in one test, and then used by subsequent tests that don't explicitly load those fixtures.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant