- How do I install this package in my Laravel project?
- Run `composer require --dev ergebnis/phpunit-slow-test-detector` to install the package. Then, add the extension to your `phpunit.xml` under the `<extensions>` tag and configure the `maximum-duration` parameter in milliseconds.
- Does this work with Laravel’s default PHPUnit setup?
- Yes, it integrates with Laravel’s default PHPUnit configuration in `phpunit.xml.dist`. Simply copy the extension and parameters to your custom `phpunit.xml` file, ensuring it overrides the default config.
- What Laravel versions and PHPUnit versions are supported?
- This package supports PHPUnit 6.5–13.x, which aligns with Laravel 5.8+ (PHPUnit 9.x+) and Laravel 9/10. It’s future-proof for Laravel 10+ with PHP 8.1+.
- Can I configure different thresholds for CI vs. local development?
- Yes, you can use environment-specific `phpunit.xml` files or override the `maximum-duration` parameter dynamically via command-line arguments or CI/CD variables.
- Will this break existing Laravel test suites?
- No, the package is non-intrusive and only adds slow-test detection logic. It won’t modify your test logic or assertions, but ensure your `phpunit.xml` properly includes the extension.
- How do I integrate slow-test alerts into GitHub Actions?
- Parse the CLI output in your workflow using `grep` or `awk` to filter slow-test messages, then trigger notifications via Slack, email, or other tools. Example: `phpunit | grep 'slow test' && curl -X POST -d @- SLACK_WEBHOOK`.
- Is this compatible with PestPHP, or should I use Pest’s built-in timing features?
- If you’re using PestPHP, this package is redundant since Pest has a native `--min-time` flag. Only use this if you rely on PHPUnit’s richer ecosystem or need advanced reporting.
- How do I handle false positives in CI/CD pipelines?
- Start with a conservative threshold (e.g., 1000ms) and adjust based on your test suite’s baseline. Monitor false positives in CI and refine thresholds or exclude specific tests using PHPUnit’s `@group` annotations.
- Does this package add significant overhead to test runs?
- No, the package adds minimal overhead—typically under 5% runtime impact. Benchmark your suite before and after installation to confirm performance isn’t degraded.
- Can I use this in a Laravel project that uses custom PHPUnit extensions?
- Yes, but ensure your custom extensions are compatible with PHPUnit 6.5+. If conflicts arise, test in a staging environment or consult the package’s GitHub issues for troubleshooting.