- How do I install ParaTest in a Laravel project?
- Run `composer require --dev brianium/paratest` to add ParaTest as a dev dependency. No Laravel-specific setup is needed—just replace `phpunit` with `vendor/bin/paratest` in your scripts or CI pipelines.
- Will ParaTest break my existing Laravel test suite?
- ParaTest is designed for drop-in compatibility, but tests relying on static state (e.g., singletons, shared database connections) may fail. Audit for static variables or global services before switching. Use `TEST_TOKEN` for database isolation if needed.
- Does ParaTest support Laravel’s database testing (e.g., migrations, factories)?
- Yes, but you’ll need to use `TEST_TOKEN` to isolate database schemas per process. Example: `DB_CONNECTION=sqlite_testing_${TEST_TOKEN}` in your `phpunit.xml`. ParaTest guarantees unique tokens for each test run.
- Can I use ParaTest with Laravel’s built-in PHPUnit configuration?
- Absolutely. ParaTest reads your existing `phpunit.xml` or `phpunit.php`—no changes are required unless you need database isolation (e.g., `TEST_TOKEN`-prefixed connections). It even supports Laravel’s `APP_ENV=testing` defaults.
- How do I parallelize tests by individual test methods, not just TestCase classes?
- Use the `--functional` flag: `vendor/bin/paratest --functional`. This splits tests at the method level (e.g., `testUserCreation` and `testUserDeletion` run in parallel) instead of the default TestCase-level parallelism.
- Does ParaTest work with Laravel’s Pest or other testing frameworks?
- No, ParaTest is specifically for PHPUnit. If you use Pest, consider alternatives like `pest --parallel` or `php-parallel-lint`. ParaTest integrates directly with PHPUnit’s internals, so Laravel’s PHPUnit-based tests (e.g., `phpunit --testsuite=unit`) are fully supported.
- How do I configure code coverage in CI with ParaTest?
- ParaTest merges coverage reports automatically. In CI, set `XDEBUG_MODE=coverage` and run `vendor/bin/paratest --coverage-clover=coverage.clover`. For GitHub Actions, add `env: XDEBUG_MODE: coverage` to your test job.
- What Laravel versions and PHPUnit versions does ParaTest support?
- ParaTest requires **PHP 8.1+** and **PHPUnit 13+** (as of v7.21+). Laravel 9+ projects using the latest PHPUnit are fully compatible. Older PHPUnit versions (e.g., v9) will fail—upgrade via `composer require --dev phpunit/phpunit:^13`.
- Can I limit the number of parallel processes in CI to avoid resource spikes?
- Yes, use `--processes=N` (e.g., `--processes=4`) or `--max-processes=N` to cap concurrency. Start with `--processes=2` in CI to benchmark, then adjust based on your runner’s memory/CPU limits (e.g., GitHub Actions small vs. large runners).
- Are there alternatives to ParaTest for Laravel parallel testing?
- For PHPUnit, alternatives include `php-parallel-lint` (for linting) or custom scripts with `pcntl_fork()`. For Pest, use `pest --parallel`. However, ParaTest is the most mature PHPUnit-specific solution with built-in coverage merging and `TEST_TOKEN` isolation.