Is anyone able to explain what this actually means? The documentation seems to say that it is similar to setting an order (--seed 123 # same as --order rand:123
), but from what I can tell doesn't seem to go into it any further. I'm assuming it's not related to database seed data, but I could well be wrong.
In the default configuration, RSpec runs its tests in random order.
This is considered a good practice because tests should be independent of each other. Running them in a random order helps to find tests that only pass when they are run in a specific order and fail in another order.
But the problem is: When RSpec runs the test in random order and then fails, how can you re-run the test in the exact same order again to debug the issue?
That can be done by telling RSpec to use the same seed for its randomness as it was used before.
RSpec tells you this seed when it is starting:
$ rspec spec
Randomized with seed 48111
.....*.........
To re-run the specs in the exact same order run:
$ rspec spec --seed 48111
Reading about Random#seed
might be interesting in this context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With