Class: ActiveSupport::TestCase

Inherits:
Minitest::Test
  • Object
show all
Extended by:
ActiveSupport::Testing::Declarative
Includes:
ActiveRecord::TestFixtures, ActiveSupport::Testing::Assertions, ActiveSupport::Testing::Deprecation, ActiveSupport::Testing::FileFixtures, ActiveSupport::Testing::SetupAndTeardown, ActiveSupport::Testing::TaggedLogging, ActiveSupport::Testing::TimeHelpers
Defined in:
activesupport/lib/active_support/test_case.rb,
railties/lib/rails/test_help.rb

Constant Summary collapse

Assertion =
Minitest::Assertion

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActiveSupport::Testing::Declarative

test

Methods included from ActiveRecord::TestFixtures

#after_teardown, #before_setup, #enlist_fixture_connections, #run_in_transaction?, #setup_fixtures, #teardown_fixtures

Methods included from Concern

#append_features, #class_methods, extended, #included

Methods included from ActiveSupport::Testing::FileFixtures

#file_fixture

Methods included from ActiveSupport::Testing::TimeHelpers

#travel, #travel_back, #travel_to

Methods included from ActiveSupport::Testing::Deprecation

#assert_deprecated, #assert_not_deprecated, #collect_deprecations

Methods included from ActiveSupport::Testing::Assertions

#assert_difference, #assert_no_difference, #assert_not

Methods included from ActiveSupport::Testing::SetupAndTeardown

#after_teardown, #before_setup

Methods included from ActiveSupport::Testing::TaggedLogging

#before_setup

Class Method Details

.test_orderObject

Returns the order in which test cases are run.

ActiveSupport::TestCase.test_order # => :random

Possible values are :random, :parallel, :alpha, :sorted. Defaults to :random.


38
39
40
# File 'activesupport/lib/active_support/test_case.rb', line 38

def test_order
  ActiveSupport.test_order ||= :random
end

.test_order=(new_order) ⇒ Object

Sets the order in which test cases are run.

ActiveSupport::TestCase.test_order = :random # => :random

Valid values are:

  • :random (to run tests in random order)

  • :parallel (to run tests in parallel)

  • :sorted (to run tests alphabetically by method name)

  • :alpha (equivalent to :sorted)


28
29
30
# File 'activesupport/lib/active_support/test_case.rb', line 28

def test_order=(new_order)
  ActiveSupport.test_order = new_order
end

Instance Method Details

#assert_nothing_raised(*args) ⇒ Object

Assertion that the block should not raise an exception.

Passes if evaluated code in the yielded block raises no exception.

assert_nothing_raised do
  perform_service(param: 'no_exception')
end

77
78
79
80
81
82
83
84
# File 'activesupport/lib/active_support/test_case.rb', line 77

def assert_nothing_raised(*args)
  if args.present?
    ActiveSupport::Deprecation.warn(
      "Passing arguments to assert_nothing_raised " \
      "is deprecated and will be removed in Rails 5.1.")
  end
  yield
end