- How do I use liuggio/fastest to parallelize Laravel’s PHPUnit functional tests?
- Install via Composer (`composer require --dev liuggio/fastest`), then pipe your test files to fastest. For example: `find tests/Feature -name '*.php' | ./vendor/liuggio/fastest/fastest 'vendor/bin/phpunit {}'`. For database isolation, set `ENV_TEST_CHANNEL_READABLE` to a unique value per process (e.g., `DB_1`, `DB_2`).
- Does liuggio/fastest work with Laravel’s default PHPUnit version (v9+)?
- Yes, fastest is compatible with PHPUnit 9+ and Laravel’s default setup. It avoids deprecated APIs and integrates seamlessly with Laravel’s test suite. For legacy PHPUnit versions, ensure your Laravel project isn’t using outdated dependencies.
- Can I use fastest with Laravel Dusk or Pest for browser tests?
- Yes, but you’ll need to configure `FastestEnvironment::setFromRequest()` in your `app_dev.php` or middleware to ensure per-process isolation. For Dusk, this prevents browser conflicts, and for Pest, it works similarly to PHPUnit. Example: `FastestEnvironment::setFromRequest($request);`.
- How does fastest handle database connections for parallel Laravel tests?
- Fastest supports per-process database isolation via the `ENV_TEST_CHANNEL_READABLE` environment variable. For Laravel, configure Doctrine adapters in `config/database.php` (e.g., SQLite paths with `__DBNAME__` placeholders) or use separate database connections for each process. This eliminates race conditions in functional tests.
- Will fastest break my CI/CD pipeline if I enable parallel testing?
- No, fastest is CI/CD-friendly and requires no infrastructure changes. Use it in GitHub Actions or CircleCI like this: `fastest -x phpunit.xml 'vendor/bin/phpunit --testdox-html=report_{n}.html'`. Monitor resource usage (e.g., `nproc --all` for core count) to avoid memory limits.
- How do I debug flaky tests when using fastest’s randomization?
- Disable randomization with `--preserve-order` to debug flaky tests. Use `-vvv` for verbose output to trace failures to specific processes. For shared state issues (e.g., caches), consider `--preserve-order` or isolate state per process.
- Can liuggio/fastest run Behat scenarios in parallel for Laravel projects?
- Yes, fastest includes a Behat extension. Pipe your Behat scenarios like this: `./vendor/liuggio/fastest/fastest 'vendor/bin/behat --config=behat.yml {}'`. Ensure your Behat environment supports parallel execution (e.g., no shared session state).
- What’s the performance impact of using fastest for unit tests in Laravel?
- Fastest is optimized for functional/integration tests, not unit tests. The overhead of process creation can outweigh benefits for fast unit tests. Stick to PHPUnit’s native parallelization (`--parallel`) for unit tests and reserve fastest for slower, database-dependent tests.
- How do I merge coverage reports when using fastest with Laravel?
- Use `phpcov/phpunit-merger` to combine coverage reports from parallel processes. Example: `fastest -x phpunit.xml 'vendor/bin/phpunit --coverage-clover=coverage_{n}.xml' && phpcov merge coverage_*.xml coverage-final.xml`. Document this workflow in your team’s testing guide.
- Are there alternatives to liuggio/fastest for parallel testing in Laravel?
- Yes, alternatives include `paratest` (PHPUnit-specific, global state risks) and `php-parallel-lint` (for linting). However, fastest stands out for Laravel due to its database isolation support, tool-agnostic design, and minimal setup. For Behat, `parallel` CLI tools exist but lack Laravel-specific optimizations.