- Can I use brianium/paratest with Laravel’s default PHPUnit 10/11 without upgrading?
- No, ParaTest requires PHPUnit 13+ due to its reliance on internal APIs. If upgrading isn’t feasible, you’d need to fork ParaTest to support older versions, but this adds maintenance overhead. Check your Laravel version’s PHPUnit compatibility first.
- How do I handle Laravel’s RefreshDatabase trait with parallel tests?
- ParaTest’s TEST_TOKEN environment variable lets you assign unique database names per process (e.g., `testdb_$TEST_TOKEN`). This avoids conflicts with Laravel’s transaction rollbacks. Disable transactions entirely if needed, but TEST_TOKEN isolation is the recommended approach.
- Will ParaTest break tests that use static state or App::singleton()?
- Yes, static state or Laravel’s service container singletons can cause race conditions. Refactor tests to use dependency injection or move shared logic to non-test classes. ParaTest’s UNIQUE_TEST_TOKEN can help isolate some cases, but static variables are inherently unsafe.
- How do I configure ParaTest for GitHub Actions CI with Laravel?
- Replace `phpunit` with `paratest` in your workflow. Use `--coverage` for combined coverage reports and limit initial processes with `--max-processes=4` to validate stability. Example: `vendor/bin/paratest --coverage --max-processes=4 tests/Unit`.
- Does ParaTest support Laravel’s MigrateFresh or other test database helpers?
- Yes, but ensure your test classes use TEST_TOKEN for database names (e.g., `testdb_$TEST_TOKEN`). MigrateFresh will run per process, but you may need to adjust migrations to handle parallel schema changes or use `--parallel` cautiously.
- How do I debug failing tests in parallel mode?
- Use `paratest_for_phpstorm` for IDE debugging or run with `--verbose` to see process IDs. Check for race conditions in tests using shared resources (e.g., files, static caches). ParaTest’s output includes sharding details to identify problematic test groups.
- What’s the best way to test flaky tests in parallel?
- Start with `--max-processes=2` to isolate flakes, then gradually increase. Use `UNIQUE_TEST_TOKEN` to log process-specific data (e.g., timestamps) and compare runs. If flakes persist, revert to sequential tests or refactor the test to avoid shared dependencies.
- Can I use ParaTest with Laravel’s Pest testing framework?
- No, ParaTest is designed for PHPUnit only. Pest uses a different test runner and doesn’t integrate with ParaTest’s parallelization logic. Stick to PHPUnit for parallel testing in Laravel.
- How does ParaTest handle code coverage for Laravel’s PCOV setup?
- ParaTest combines coverage from all processes into a single report when using `--coverage`. Ensure your `phpunit.xml` includes `<coverage>` config and that PCOV is installed. For xDebug, use `--coverage-xdebug` instead. CI pipelines may need adjusted coverage thresholds.
- What’s the fallback if ParaTest introduces instability in production?
- Revert to sequential tests by removing ParaTest from `composer.json` and running `phpunit` directly. Cache test results (e.g., with `--cache-result`) to avoid reprocessing. Monitor CI runs closely after migration to catch regressions early.