class ActiveSupport::TestCase

def inspect # :nodoc:

:nodoc:
def inspect # :nodoc:
  Object.instance_method(:to_s).bind_call(self)
end

def parallelize(workers: :number_of_processors, with: :processes, threshold: ActiveSupport.test_parallelization_threshold)

50, and it's configurable via +config.active_support.test_parallelization_threshold+.
number of tests to run is above the +threshold+ param. The default value is
Because parallelization presents an overhead, it is only enabled when the

The processes parallelization uses a Ruby DRb server.
The threaded parallelization uses minitest's parallel executor directly.

parallelize(workers: :number_of_processors, with: :threads)

database and will not work with system tests at this time.
method. Note the threaded parallelization does not create multiple
use threads instead you can pass with: :threads to the +parallelize+
The default parallelization method is to fork processes. If you'd like to

set to the actual core count on the machine you are on.
If +workers+ is set to +:number_of_processors+, the number of workers will be

parallelized.
If the number of workers is set to +1+ or fewer, the tests will not be

you do for local testing.
environments, or other environments where you may need more workers than
and the environment variable will be used instead. This is useful for CI
If ENV["PARALLEL_WORKERS"] is set the workers argument will be ignored

test-database-1
test-database-0

with the worker number.
is forked. For each process a new database will be created suffixed
Takes a +workers+ argument that controls how many times the process

Parallelizes the test suite.
def parallelize(workers: :number_of_processors, with: :processes, threshold: ActiveSupport.test_parallelization_threshold)
  workers = Concurrent.physical_processor_count if workers == :number_of_processors
  workers = ENV["PARALLEL_WORKERS"].to_i if ENV["PARALLEL_WORKERS"]
  return if workers <= 1
  Minitest.parallel_executor = ActiveSupport::Testing::ParallelizeExecutor.new(size: workers, with: with, threshold: threshold)
end

def parallelize_setup(&block)

end
end
# create databases
parallelize_setup do
class ActiveSupport::TestCase

In your +test_helper.rb+ add the following:

Note: this feature is not available with the threaded parallelization.

but before the tests run.
databases or any behavior that needs to be run after the process is forked
Set up hook for parallel testing. This can be used if you have multiple
def parallelize_setup(&block)
  ActiveSupport::Testing::Parallelization.after_fork_hook(&block)
end

def parallelize_teardown(&block)

end
end
# drop databases
parallelize_teardown do
class ActiveSupport::TestCase

In your +test_helper.rb+ add the following:

Note: this feature is not available with the threaded parallelization.

the tests finish. This runs before the forked process is closed.
if your app uses multiple write/read databases or other clean up before
Clean up hook for parallel testing. This can be used to drop databases
def parallelize_teardown(&block)
  ActiveSupport::Testing::Parallelization.run_cleanup_hook(&block)
end

def test_order

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

ActiveSupport::TestCase.test_order # => :random

Returns the order in which test cases are run.
def test_order
  ActiveSupport.test_order ||= :random
end

def test_order=(new_order)

* +:alpha+ (equivalent to +:sorted+)
* +:sorted+ (to run tests alphabetically by method name)
* +:parallel+ (to run tests in parallel)
* +:random+ (to run tests in random order)
Valid values are:

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

Sets the order in which test cases are run.
def test_order=(new_order)
  ActiveSupport.test_order = new_order
end