- How do I install Paraunit for Laravel projects?
- Run `composer require --dev facile-it/paraunit` in your Laravel project. No additional Laravel-specific setup is needed—it replaces `phpunit` commands with `vendor/bin/paraunit run`. The package includes a one-time bootstrap prompt for `phpunit.xml` configuration.
- Does Paraunit work with Laravel’s database transactions in parallel?
- Parallel execution can conflict with Laravel’s database transactions due to race conditions. Mitigate this by using `--stop-on-failure` or isolating transaction-heavy tests (e.g., API tests) into separate suites. Stateless tests (e.g., unit tests) run safely in parallel.
- What Laravel versions and PHPUnit versions does Paraunit support?
- Paraunit requires PHPUnit 10.5.4+ (most modern Laravel apps use this). For Laravel 9+, ensure your `phpunit.xml` targets PHPUnit 10+. Check compatibility [here](https://github.com/facile-it/paraunit#compatibility) for Symfony/PHPUnit version mappings.
- Can I use Paraunit for code coverage in Laravel CI (e.g., GitLab, GitHub Actions)?
- Yes. Run `vendor/bin/paraunit coverage --html=./coverage` to generate parallel coverage reports. It auto-selects the best driver (Pcov/Xdebug/PHPDbg) and supports Cobertura format for CI tools like GitLab. For precise metrics, prefer Pcov/Xdebug in CI environments.
- How do I debug race conditions or parallel test failures in Laravel?
- Use `--stop-on-failure` to halt on the first failure, or `--debug` for verbose output. Isolate stateful tests (e.g., API/database tests) and reduce parallelism with `--chunk-size=N`. Check for shared state like static variables or singletons in Laravel’s `AppServiceProvider` or test helpers.
- Will Paraunit break Laravel’s custom PHPUnit listeners or test hooks?
- Paraunit leverages PHPUnit’s event system (v10+), so most Laravel listeners (e.g., `BeforeTestClass`) should work. However, listeners modifying global state (e.g., app bindings) may cause race conditions. Test with `--stop-on-failure` first to identify conflicts.
- How much faster is Paraunit for Laravel test suites, and does it work locally?
- Paraunit can reduce test execution time by **70%+** for large suites (e.g., 1000+ tests) by utilizing all CPU cores. It works locally and in CI, but local speedups depend on your machine’s cores. For CI, prioritize stateless tests to maximize gains.
- Are there alternatives to Paraunit for parallel PHPUnit tests in Laravel?
- Alternatives include `php-parallel-lint` (for linting) or custom scripts using `pcntl_fork`, but Paraunit is the most Laravel-friendly option. It integrates natively with Symfony’s CLI (used by Laravel) and handles coverage collection, unlike generic parallel tools.
- How do I configure Paraunit to exclude specific Laravel test groups?
- Use PHPUnit’s standard flags with Paraunit, e.g., `vendor/bin/paraunit run --exclude-group=integration`. All PHPUnit options (e.g., `--group`, `--filter`) are supported. For Laravel, exclude stateful groups like `Feature` or `Database` if they cause race conditions.
- Does Paraunit support Laravel’s SQLite test databases in parallel?
- SQLite is generally safe for parallel execution, but MySQL/PostgreSQL may struggle with concurrent connections. For Laravel, use SQLite for unit tests and isolate database-heavy tests. Monitor CI resource usage—Paraunit’s `--chunk-size` can limit parallelism to avoid DB overload.