class ActiveSupport::TestCase
def parallelize(workers: :number_of_processors, with: :processes, threshold: ActiveSupport.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)
databases and will not work with system tests.
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"] Minitest.parallel_executor = ActiveSupport::Testing::ParallelizeExecutor.new(size: workers, with: with, threshold: threshold) end