Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To run PHPUnit tests in parallel, install ParaTest as a Composer development dependency and run vendor/bin/paratest. For Laravel, use php artisan test --parallel. Parallel execution can shorten a suite’s runtime, but its actual benefit depends on available CPU, memory, databases, and other shared resources—and tests must be designed to avoid interfering with one another.

Install ParaTest and run your PHPUnit suite

ParaTest is a commonly documented parallel runner for PHPUnit. Its maintainers describe its objective as supporting parallel testing in PHPUnit. It can distribute work by test case or, in functional mode, by individual test. See the ParaTest project for current package and PHPUnit compatibility details; compatibility can change as PHPUnit releases evolve.

  1. From your project directory, install ParaTest as a development dependency: composer require --dev brianium/paratest.

  2. Run the suite with vendor/bin/paratest.

  3. To use functional-style parallelization, run vendor/bin/paratest --functional.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check the current ParaTest package constraints against the PHPUnit version in your project before upgrading or installing. The project’s README documents supported versions and runner options.

Run Laravel tests in parallel

Laravel provides a parallel test command through its Artisan test runner. Install ParaTest, then invoke the command:

  1. Install the dependency: composer require brianium/paratest --dev.

  2. Run tests in parallel: php artisan test --parallel.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Laravel defaults to as many processes as available CPU cores. To set a specific count, add the process option; for example, php artisan test --parallel --processes=4. Laravel’s documentation explains its parallel testing behavior.

Choose a worker count by measuring the full suite

More workers do not guarantee faster tests. Begin with a worker count near the machine’s available cores, then benchmark the complete suite on the same kind of machine used in CI. Watch for bottlenecks beyond CPU:

There is no universal speed-up percentage established by the cited project documentation. Compare sequential and parallel runs using the same suite and environment, and choose the worker count that gives the best reliable throughput without exhausting resources.

Prevent workers from sharing mutable test resources

Each worker runs in a separate PHP interpreter. Do not assume that static state, one-time initialization, or setup performed by one process will be shared safely with another. ParaTest specifically notes limitations around shared static methods, static variables, and test-class code consumed by other test classes in its wrapper runner. See its runner documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use ParaTest’s worker tokens to partition resources. TEST_TOKEN differs from every other currently running test, making it useful for resources that only need to be unique among concurrent workers. UNIQUE_TEST_TOKEN is unique across a run and process. ParaTest documents these variables in its environment-variable guidance.

Laravel database isolation

When a primary database connection is configured, Laravel creates a separate test database for each parallel process by adding a process token to the database name. Those databases persist between test commands by default. Laravel documents the behavior and configuration in its parallel testing guide. This database separation does not automatically isolate caches, files, ports, external services, or other shared resources.

Collect code coverage from parallel runs

ParaTest can combine coverage output from parallel processes, but the coverage engine must already work with ordinary sequential PHPUnit. Configure PCOV or Xdebug for the worker processes as well as the parent command.

PCOV

Pass the PHP option to ParaTest, for example:

php -d pcov.enabled=1 vendor/bin/paratest --passthru-php="'-d' 'pcov.enabled=1'"

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Xdebug

Enable coverage mode in the environment:

XDEBUG_MODE=coverage vendor/bin/paratest

ParaTest’s coverage notes and command options are documented in the project README. If coverage works sequentially but is missing or incomplete in parallel, confirm the option reaches each worker and that the configured driver is enabled for the PHP processes ParaTest starts.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Debug intermittent failures and subprocess errors

When a parallel run fails, first rerun the failing test or suite sequentially to distinguish a test defect from a process or resource interaction. Then check whether workers share a database, file path, cache key, port, external account, or one-time setup step. ParaTest’s verbose mode prints the originating subprocess command when a subprocess fails; copy that command and run it directly to inspect the failure. Removing ParaTest’s internal null printer restores normal PHPUnit output for debugging. See the ParaTest troubleshooting guidance.

ParaTest and Paraunit: what to compare

ParaTest is a widely documented PHPUnit parallel runner, but it is not the only option. Paraunit documents commands including vendor/bin/paraunit run and vendor/bin/paraunit coverage --html=./dir. Its supported PHPUnit versions vary by Paraunit release. Before choosing or switching, compare the current projects on the details that affect your setup:

Decision point What to verify
PHPUnit compatibility Check the release-specific compatibility information for the PHPUnit version in your project.
Scheduling Determine whether work is distributed by test case, individual test, or another mode that suits your suite.
Coverage Verify that parallel coverage aggregation supports your configured driver and output workflow.
Resource isolation Confirm how workers identify themselves and how your databases and other shared resources will be separated.
Framework integration Check whether your framework already provides a supported command or setup for parallel execution.
Debugging Review how to reproduce a failed worker command and recover useful test output.

Paraunit’s commands and compatibility information are available in its project documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.