From 5f777e4b5ee2e3e8e6fd0e2a208ec2a4d25a960d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 2 Jan 2015 22:43:06 -0300 Subject: [PATCH] Change the default test order from `:sorted` to `:random` --- activesupport/CHANGELOG.md | 4 ++++ activesupport/lib/active_support/test_case.rb | 20 +++------------- activesupport/test/test_case_test.rb | 24 +++++++++---------- 3 files changed, 18 insertions(+), 30 deletions(-) diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index be9c8a04b7760..aa2090b8974be 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,3 +1,7 @@ +* Change the default test order from `:sorted` to `:random`. + + *Rafael Mendonça França* + * Remove deprecated `ActiveSupport::JSON::Encoding::CircularReferenceError`. *Rafael Mendonça França* diff --git a/activesupport/lib/active_support/test_case.rb b/activesupport/lib/active_support/test_case.rb index 98b68455ab55a..aa71db3c565a2 100644 --- a/activesupport/lib/active_support/test_case.rb +++ b/activesupport/lib/active_support/test_case.rb @@ -31,29 +31,15 @@ def test_order=(new_order) # Returns the order in which test cases are run. # - # ActiveSupport::TestCase.test_order # => :sorted + # ActiveSupport::TestCase.test_order # => :random # # Possible values are +:random+, +:parallel+, +:alpha+, +:sorted+. - # Defaults to +:sorted+. + # Defaults to +:random+. def test_order test_order = ActiveSupport.test_order if test_order.nil? - ActiveSupport::Deprecation.warn "You did not specify a value for the " \ - "configuration option `active_support.test_order`. In Rails 5, " \ - "the default value of this option will change from `:sorted` to " \ - "`:random`.\n" \ - "To disable this warning and keep the current behavior, you can add " \ - "the following line to your `config/environments/test.rb`:\n" \ - "\n" \ - " Rails.application.configure do\n" \ - " config.active_support.test_order = :sorted\n" \ - " end\n" \ - "\n" \ - "Alternatively, you can opt into the future behavior by setting this " \ - "option to `:random`." - - test_order = :sorted + test_order = :random self.test_order = test_order end diff --git a/activesupport/test/test_case_test.rb b/activesupport/test/test_case_test.rb index 5e852c8050866..151b623171a07 100644 --- a/activesupport/test/test_case_test.rb +++ b/activesupport/test/test_case_test.rb @@ -182,30 +182,28 @@ def teardown ActiveSupport::TestCase.test_order = @original_test_order end - def test_defaults_to_sorted_with_warning + def test_defaults_to_random ActiveSupport::TestCase.test_order = nil - assert_equal :sorted, assert_deprecated { ActiveSupport::TestCase.test_order } + assert_equal :random, ActiveSupport::TestCase.test_order - # It should only produce a deprecation warning the first time this is accessed - assert_equal :sorted, assert_not_deprecated { ActiveSupport::TestCase.test_order } - assert_equal :sorted, assert_not_deprecated { ActiveSupport.test_order } + assert_equal :random, ActiveSupport.test_order end def test_test_order_is_global - ActiveSupport::TestCase.test_order = :random - - assert_equal :random, ActiveSupport.test_order - assert_equal :random, ActiveSupport::TestCase.test_order - assert_equal :random, self.class.test_order - assert_equal :random, Class.new(ActiveSupport::TestCase).test_order - - ActiveSupport.test_order = :sorted + ActiveSupport::TestCase.test_order = :sorted assert_equal :sorted, ActiveSupport.test_order assert_equal :sorted, ActiveSupport::TestCase.test_order assert_equal :sorted, self.class.test_order assert_equal :sorted, Class.new(ActiveSupport::TestCase).test_order + + ActiveSupport.test_order = :random + + assert_equal :random, ActiveSupport.test_order + assert_equal :random, ActiveSupport::TestCase.test_order + assert_equal :random, self.class.test_order + assert_equal :random, Class.new(ActiveSupport::TestCase).test_order end def test_i_suck_and_my_tests_are_order_dependent!