liuggio/fastest
Run tests in parallel with a simple CLI wrapper. Fastest executes any command (PHPUnit, Behat, etc.) across available CPU cores, randomizes test order, supports piping test lists or phpunit.xml, adds verbosity flags, and helps functional tests use one DB per process.
Installation:
composer require --dev liuggio/fastest
Or globally:
composer global require liuggio/fastest
Basic Usage:
Pipe test files to fastest with your test command:
find tests/ -name "*Test.php" | ./vendor/liuggio/fastest/fastest "vendor/bin/phpunit {}"
Or use the bin/ directory if configured:
find tests/ -name "*Test.php" | ./bin/fastest "bin/phpunit {}"
First Use Case: Run PHPUnit tests in parallel using database isolation for functional tests:
find tests/Feature -name "*Test.php" | ./bin/fastest -b"php artisan migrate --env=testing --database=test_{p}" "bin/phpunit {}"
Parallel Test Execution:
find or ls to pipe test files:
ls tests/Unit | ./bin/fastest "bin/phpunit {}"
./bin/fastest -o "bin/phpunit {}"
Database Isolation for Functional Tests:
ENV_TEST_CHANNEL_READABLE) to dynamically configure database names:
// config/database.php
'connections' => [
'test_{p}' => [
'url' => env('DATABASE_URL').'_test_'.env('ENV_TEST_CHANNEL_READABLE'),
],
],
./bin/fastest -b"php artisan migrate --env=testing_{p}" "bin/phpunit {}"
Code Coverage Merging:
find tests/ -name "*Test.php" | ./bin/fastest "bin/phpunit --coverage-text --coverage-clover=coverage/{n}.xml {}"
phpcov:
phpcov merge coverage/ --html=coverage/merged
Behat Integration:
./bin/behat --list-scenarios | ./bin/fastest "./bin/behat {}"
behat.yml:
extensions:
Liuggio\Fastest\Behat\ListFeaturesExtension\Extension: ~
Custom Commands:
find src/ -name "*.php" | ./bin/fastest "phpstan analyze --memory-limit=1G {}"
Symfony Integration:
# config/packages/doctrine.yaml
doctrine:
dbal:
connection_factory: Liuggio\Fastest\Doctrine\DBAL\ConnectionFactory
__DBNAME__ placeholder in path:
doctrine:
dbal:
driver: pdo_sqlite
path: "%kernel.cache_dir%/__DBNAME__.sqlite"
Environment Setup:
ENV_TEST_CHANNEL_READABLE in your test environment (e.g., .env.testing):
ENV_TEST_CHANNEL_READABLE=test_${ENV_TEST_CHANNEL}
CI/CD Pipelines:
--no-progress for cleaner logs:
./bin/fastest --no-progress "bin/phpunit {}"
./bin/fastest -p4 "bin/phpunit {}"
Debugging:
./bin/fastest -vvv "bin/phpunit {}"
Environment Variables:
variables_order in php.ini includes E (e.g., EAC):
variables_order = "EGPCS"
PATH may fail if environment variables are not set correctly.Database Connections:
__DBNAME__ with ENV_TEST_CHANNEL_READABLE in the path.--rerun-failed:
./bin/fastest -b"php artisan cache:clear" -r "bin/phpunit {}"
Behat Scenarios:
--list-scenarios for scenario outlines (duplicate test names in JUnit reports).--list-features for safer JUnit merging:
./bin/behat --list-features | ./bin/fastest "./bin/behat {}"
Resource Limits:
./bin/fastest -p2 "bin/phpunit --memory-limit=512M {}"
Order Dependencies:
-o) if tests assume execution order (e.g., setup/teardown).Verbose Output:
-vvv to debug process assignment:
./bin/fastest -vvv "bin/phpunit {}"
Process Isolation:
dd([
'Channel' => getenv('ENV_TEST_CHANNEL_READABLE'),
'Test File' => getenv('ENV_TEST_ARGUMENT'),
]);
Failed Tests:
-r:
./bin/fastest -r "bin/phpunit {}"
Custom Placeholders:
{p}, {n}, or {} in commands for dynamic values:
./bin/fastest "bin/phpunit --filter={n} {}"
Custom Adapters:
Liuggio\Fastest\Doctrine\DBAL\ConnectionFactory for other ORMs (e.g., Eloquent).Pre/Post Commands:
-b (before) or add post-processing scripts:
./bin/fastest -b"php artisan migrate" "bin/phpunit {}" && php artisan optimize
Progress Bar:
--no-progress for CI output:
./bin/fastest --no-progress "bin/phpunit {}"
Cross-Platform:
PATH issues:
./bin/fastest "/full/path/to/phpunit {}"
How can I help you explore Laravel packages today?