cleatsquad / module-parallel-tests-plus
Magento 2 module that enhances the dev:tests:run CLI command by enabling ParaTest parallel execution using --processes and --runner options.
Package info
github.com/CleatSquad/module-parallel-tests-plus
Type:magento2-module
pkg:composer/cleatsquad/module-parallel-tests-plus
Requires
- php: ~8.2|~8.3|~8.4
- brianium/paratest: ^6.0 || ^7.4
- magento/module-developer: ^100.4
- symfony/process: ^5.4 || ^6.0 || ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^10.5 || ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-01 07:24:12 UTC
README
A Magento 2 extension that enhances the core dev:tests:run command by enabling parallel execution of developer tests using ParaTest.
This module significantly reduces execution time for static, unit, integration and integrity tests β via a clean declarative DI override (no core file patching) and full CI/CD compatibility.
Badges
β¨ Features
- π Parallel execution of Magento developer tests.
- π§ Adds
--processesto set worker count. - π§΅ Adds
--runneroption (default:WrapperRunner). - β Fully compatible with Magentoβs native
--argumentspassthrough. - π§© Supports all Magento test categories:
- Static Test Suites (Default, Legacy, JS Exemplar)
- Unit Tests (Framework + Integration Layer)
- Integration Tests
- Integrity Tests
- π‘ Clean DI override of:
Magento\Developer\Console\Command\DevTestsRunCommand - π― No core hacks. Safe for production and CI pipelines.
π¦ Installation
You can install this module using Composer (recommended) or manually.
πΉ 1. Install via Composer (recommended)
composer require cleatsquad/module-parallel-tests-plus --dev
Note: this package depends on
magento/module-developer, resolved viarepo.magento.com. Make sure your project has a valid Magento Marketplaceauth.jsonconfigured, otherwise Composer will fail to resolve it.
Then upgrade Magento:
bin/magento setup:upgrade
πΉ 2. Manual installation (app/code)
Copy the module
app/code/CleatSquad/ParallelTestsPlus
Require ParaTest
composer require --dev brianium/paratest
Then upgrade Magento:
bin/magento setup:upgrade
π Usage
Run static tests with 8 workers
bin/magento dev:tests:run static --processes=8
Run unit tests with 3 workers
bin/magento dev:tests:run unit --processes=3
Run all developer tests in parallel
bin/magento dev:tests:run all --processes=8
Use a custom runner
bin/magento dev:tests:run static --runner=WrapperRunner
Pass arguments to ParaTest/PHPUnit via Magento native --arguments
bin/magento dev:tests:run static -c" --filter=MyTest"
bin/magento dev:tests:run integration --processes 2 -c" testsuite/Magento/Catalog/Model/ResourceModel/Category/CollectionTest.php"
bin/magento dev:tests:run static -c" --filter=\"Test::testMethod with data (1)\""
--arguments is split into tokens honoring quotes (so a quoted value can
contain spaces, as in the last example above) and the resulting ParaTest
command is executed directly as an argv array - never through a shell. Shell
metacharacters (;, |, `, $(...), ...) inside an argument are
always treated as literal text, never interpreted.
Isolate the database for parallel integration tests
bin/magento dev:tests:run integration --processes=4 --isolate-db
Magento's dev/tests/integration suite is built around a single shared
database (see install-config-mysql.php), global transactions and
synchronous fixture loading/cleanup. Running it with --processes greater
than 1 without isolation can produce deadlocks, ID collisions and flaky,
non-reproducible failures.
--isolate-db avoids this without ever modifying install-config-mysql.php:
- It provisions one database named
<db-name>_<worker>(e.g.magento_integration_tests_1,_2, ...) viaCREATE DATABASE IF NOT EXISTSβ existing databases are never modified or dropped. - It writes one
install-config-mysql_<worker>.phpper worker (a plain copy of the base config withdb-namesuffixed) plus a small bootstrap wrapper, all under a directory unique to this run (dev/tests/integration/.parallel-tests-plus-runs/<runId>/). The originalinstall-config-mysql.phpis only ever read, never written to. - ParaTest is invoked with
--bootstrappointing at that wrapper, which resolves each worker's config file from ParaTest's per-workerTEST_TOKENenvironment variable before delegating to Magento's realdev/tests/integration/framework/bootstrap.php. Magento's own bootstrap then installs and owns each database independently, exactly as it already does for the single shared one. - The run's directory is removed once the run finishes.
Because every artifact is additive and scoped to a single, uniquely-named
run directory, two --isolate-db runs (two CI jobs, two terminals) never
collide, and an interrupted run (SIGKILL, OOM, docker stop) leaves only
an inert leftover directory β never a shared config file stuck in a
half-rewritten state blocking subsequent runs.
Requirements: --processes > 1, an existing install-config-mysql.php
(without it there is nothing to isolate β the flag is silently ignored),
and a MySQL user allowed to CREATE DATABASE. If provisioning fails (e.g.
unreachable host), the run aborts before any file is written.
--isolate-db is only applied to integration/integration-all; it is a
no-op for unit, static and other types, which don't share mutable state
and are already safe to parallelize.
ParaTest / PHPUnit version compatibility
brianium/paratest is required as ^6.0 || ^7.4 (rather than a single
range) so Composer's solver can pick whichever major is compatible with the
phpunit/phpunit version already constrained by your project (paratest
^6.0 needs phpunit ^9.0; paratest ^7.x needs phpunit ^10.0 || ^11.0 || ^12.0). Every run also checks the versions that actually got installed and
prints a warning if they're a known-incompatible pair, instead of letting it
fail with a confusing PHPUnit/ParaTest bootstrap error.
π€ Support & Contributions
Issues and pull requests are welcome β see CONTRIBUTING.md. For security issues, see SECURITY.md instead of opening a public issue.
GitHub:
https://github.com/CleatSquad/module-parallel-tests-plus
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
π Acknowledgements
This module is powered by the excellent ParaTest project:
β‘οΈ https://github.com/paratestphp/paratest
ParaTest enables efficient parallel execution of PHPUnit tests and is essential to the performance improvements provided by this module.
Authors
- Mohamed El Mrabet - Initial work - mimou78
π License
Released under the MIT License.
See the LICENSE.txt file for full details.
Β© 2025 - CleatSquad (https://cleatsquad.dev)