facile-it/paraunit
Run PHPUnit test suites faster by executing tests in parallel across multiple processes. Includes a Symfony-based CLI, supports modern PHPUnit/Symfony versions, and can collect code coverage in parallel with automatic selection of the best available driver.
Installation:
composer require --dev facile-it/paraunit
Ensure compatibility with your PHPUnit version (check compatibility table).
First Run:
vendor/bin/paraunit run
This executes all tests in parallel using your existing PHPUnit configuration.
Verify Integration:
phpunit.xml if missing. Confirm with y to auto-configure.phpunit.xml snippet:
<phpunit ...>
<extensions>
<bootstrap class="Facile\Paraunit\Bootstrap"/>
</extensions>
</phpunit>
phpunit with paraunit run in your pipeline.vendor/bin/paraunit coverage --html=./coverage
Paraunit auto-detects the fastest coverage driver (Pcov/Xdebug/PHPDbg).Replace PHPUnit Commands:
paraunit run instead of phpunit for all test executions.script:
- vendor/bin/paraunit run --stop-on-failure
Parallel Test Suites:
--testsuite:
vendor/bin/paraunit run --testsuite=Unit --testsuite=Feature
--exclude-testsuite:
vendor/bin/paraunit run --exclude-testsuite=Integration
Chunked Execution:
vendor/bin/paraunit run --chunk-size=50
Randomized Order:
vendor/bin/paraunit run --sort=random
Pass-Through Options: Forward PHPUnit flags directly:
vendor/bin/paraunit run -- --group=auth --coverage-text
Debugging Parallel Runs: Enable debug mode to inspect process outputs:
vendor/bin/paraunit run --debug
Stop-on-Failure: Halt execution on specific issues (e.g., errors, deprecations):
vendor/bin/paraunit run --stop-on-error --stop-on-deprecation
vendor/bin/paraunit coverage --cobertura=coverage.xml
vendor/bin/paraunit coverage --cache-warmup
Bootstrap Extension Missing:
paraunit run once to auto-add the <bootstrap> tag to phpunit.xml.<extensions>
<bootstrap class="Facile\Paraunit\Bootstrap"/>
</extensions>
Coverage Driver Conflicts:
pcov or xdebug is installed:
pecl install pcov # For Pcov
Paraunit auto-falls back to PHPDbg if others are unavailable.Test Dependencies:
--sort=random to mitigate flakiness or refactor tests to be isolated.Stop-on Options:
--stop-on-failure is set.vendor/bin/paraunit run --stop-on-failure tests/Unit/
Process Output:
Use --debug to see raw process logs:
vendor/bin/paraunit run --debug | grep "Process ID"
Transient Dependencies: If tests fail intermittently, check for:
--sort=random).Coverage Cache: Warm the cache before running coverage:
vendor/bin/paraunit coverage --cache-warmup --html=./coverage
PHPUnit Deprecations:
displayDetailsOnTestsThatTriggerDeprecations in phpunit.xml.false (hidden). Set to true to show details:
<phpunit ...>
<displayDetailsOnTestsThatTriggerDeprecations>true</displayDetailsOnTestsThatTriggerDeprecations>
</phpunit>
Excluded Issues:
--display-all-issues to show suppressed warnings/notices:
vendor/bin/paraunit run --display-all-issues
PHPUnit 13+:
phpunit.xml uses:
<phpunit bootstrap="vendor/autoload.php" ...>
Custom Test Selection:
Override test filtering via --test-suffix:
vendor/bin/paraunit run --test-suffix=Test.php --test-suffix=Spec.php
Symfony Integration: Paraunit works with Symfony Flex projects out-of-the-box. For custom setups:
symfony/flex is installed (or manually configure autoloading).Parallelism Limits:
PARALLEL_PROCESSES env var:
PARALLEL_PROCESSES=4 vendor/bin/paraunit run
Custom Bootstrap:
Extend the Facile\Paraunit\Bootstrap class to add pre-test logic:
namespace App\Tests\Bootstrap;
use Facile\Paraunit\Bootstrap as ParaunitBootstrap;
class CustomBootstrap extends ParaunitBootstrap {
public function __construct() {
// Add custom setup here
}
}
Update phpunit.xml:
<bootstrap class="App\Tests\Bootstrap\CustomBootstrap"/>
How can I help you explore Laravel packages today?