Skip to content

Commit 5f777e4

Browse files
committed
Change the default test order from :sorted to :random
1 parent d6e06ea commit 5f777e4

File tree

3 files changed

+18
-30
lines changed

3 files changed

+18
-30
lines changed

activesupport/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Change the default test order from `:sorted` to `:random`.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove deprecated `ActiveSupport::JSON::Encoding::CircularReferenceError`.
26

37
*Rafael Mendonça França*

activesupport/lib/active_support/test_case.rb

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,15 @@ def test_order=(new_order)
3131

3232
# Returns the order in which test cases are run.
3333
#
34-
# ActiveSupport::TestCase.test_order # => :sorted
34+
# ActiveSupport::TestCase.test_order # => :random
3535
#
3636
# Possible values are +:random+, +:parallel+, +:alpha+, +:sorted+.
37-
# Defaults to +:sorted+.
37+
# Defaults to +:random+.
3838
def test_order
3939
test_order = ActiveSupport.test_order
4040

4141
if test_order.nil?
42-
ActiveSupport::Deprecation.warn "You did not specify a value for the " \
43-
"configuration option `active_support.test_order`. In Rails 5, " \
44-
"the default value of this option will change from `:sorted` to " \
45-
"`:random`.\n" \
46-
"To disable this warning and keep the current behavior, you can add " \
47-
"the following line to your `config/environments/test.rb`:\n" \
48-
"\n" \
49-
" Rails.application.configure do\n" \
50-
" config.active_support.test_order = :sorted\n" \
51-
" end\n" \
52-
"\n" \
53-
"Alternatively, you can opt into the future behavior by setting this " \
54-
"option to `:random`."
55-
56-
test_order = :sorted
42+
test_order = :random
5743
self.test_order = test_order
5844
end
5945

activesupport/test/test_case_test.rb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -182,30 +182,28 @@ def teardown
182182
ActiveSupport::TestCase.test_order = @original_test_order
183183
end
184184

185-
def test_defaults_to_sorted_with_warning
185+
def test_defaults_to_random
186186
ActiveSupport::TestCase.test_order = nil
187187

188-
assert_equal :sorted, assert_deprecated { ActiveSupport::TestCase.test_order }
188+
assert_equal :random, ActiveSupport::TestCase.test_order
189189

190-
# It should only produce a deprecation warning the first time this is accessed
191-
assert_equal :sorted, assert_not_deprecated { ActiveSupport::TestCase.test_order }
192-
assert_equal :sorted, assert_not_deprecated { ActiveSupport.test_order }
190+
assert_equal :random, ActiveSupport.test_order
193191
end
194192

195193
def test_test_order_is_global
196-
ActiveSupport::TestCase.test_order = :random
197-
198-
assert_equal :random, ActiveSupport.test_order
199-
assert_equal :random, ActiveSupport::TestCase.test_order
200-
assert_equal :random, self.class.test_order
201-
assert_equal :random, Class.new(ActiveSupport::TestCase).test_order
202-
203-
ActiveSupport.test_order = :sorted
194+
ActiveSupport::TestCase.test_order = :sorted
204195

205196
assert_equal :sorted, ActiveSupport.test_order
206197
assert_equal :sorted, ActiveSupport::TestCase.test_order
207198
assert_equal :sorted, self.class.test_order
208199
assert_equal :sorted, Class.new(ActiveSupport::TestCase).test_order
200+
201+
ActiveSupport.test_order = :random
202+
203+
assert_equal :random, ActiveSupport.test_order
204+
assert_equal :random, ActiveSupport::TestCase.test_order
205+
assert_equal :random, self.class.test_order
206+
assert_equal :random, Class.new(ActiveSupport::TestCase).test_order
209207
end
210208

211209
def test_i_suck_and_my_tests_are_order_dependent!

0 commit comments

Comments
 (0)