Search by

cleatsquad / module-parallel-tests-plus

mimou78

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

Issues

Documentation

Type:magento2-module

pkg:composer/cleatsquad/module-parallel-tests-plus

Statistics

Installs: 286

Dependents: 0

Suggesters: 0

Stars: 4

1.2.0 2026-12-01 07:23 UTC

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

CI Latest Stable Version Total Downloads Latest Unstable Version License

✨ Features

  • πŸš€ Parallel execution of Magento developer tests.
  • πŸ”§ Adds --processes to set worker count.
  • 🧡 Adds --runner option (default: WrapperRunner).
  • βš™ Fully compatible with Magento’s native --arguments passthrough.
  • 🧩 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 via repo.magento.com. Make sure your project has a valid Magento Marketplace auth.json configured, 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:

  1. It provisions one database named <db-name>_<worker> (e.g. magento_integration_tests_1, _2, ...) via CREATE DATABASE IF NOT EXISTS β€” existing databases are never modified or dropped.
  2. It writes one install-config-mysql_<worker>.php per worker (a plain copy of the base config with db-name suffixed) plus a small bootstrap wrapper, all under a directory unique to this run (dev/tests/integration/.parallel-tests-plus-runs/<runId>/). The original install-config-mysql.php is only ever read, never written to.
  3. ParaTest is invoked with --bootstrap pointing at that wrapper, which resolves each worker's config file from ParaTest's per-worker TEST_TOKEN environment variable before delegating to Magento's real dev/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.
  4. 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)