Skip to content

Commit fd99abc

Browse files
committed
Add random ordering for tests
In spec/spec_helper.rb: * Uncomment `config.order = :random` to run tests randomly * Uncomment `Kernel.srand config.seed` to allow reproducible orderings
1 parent bb37dad commit fd99abc

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

spec/spec_helper.rb

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@
3838
mocks.verify_partial_doubles = true
3939
end
4040

41+
# Run specs in random order to surface order dependencies. If you find an
42+
# order dependency and want to debug it, you can fix the order by providing
43+
# the seed, which is printed after each run.
44+
# --seed 1234
45+
config.order = :random
46+
47+
# Seed global randomization in this process using the `--seed` CLI option.
48+
# Setting this allows you to use `--seed` to deterministically reproduce
49+
# test failures related to randomization by passing the same `--seed` value
50+
# as the one that triggered the failure.
51+
Kernel.srand config.seed
52+
4153
# The settings below are suggested to provide a good initial experience
4254
# with RSpec, but feel free to customize to your heart's content.
4355
=begin
@@ -70,16 +82,5 @@
7082
# particularly slow.
7183
config.profile_examples = 10
7284
73-
# Run specs in random order to surface order dependencies. If you find an
74-
# order dependency and want to debug it, you can fix the order by providing
75-
# the seed, which is printed after each run.
76-
# --seed 1234
77-
config.order = :random
78-
79-
# Seed global randomization in this process using the `--seed` CLI option.
80-
# Setting this allows you to use `--seed` to deterministically reproduce
81-
# test failures related to randomization by passing the same `--seed` value
82-
# as the one that triggered the failure.
83-
Kernel.srand config.seed
8485
=end
8586
end

0 commit comments

Comments
 (0)