- How do I install this package for Laravel projects using PHPUnit?
- Run `composer require --dev ergebnis/phpunit-slow-test-detector` in your project root. The package is designed for development use and won’t affect production. Ensure your Laravel project uses PHPUnit 6.5+ (default in Laravel 5.8+).
- Will this work with Laravel’s default PHPUnit setup?
- Yes, it integrates seamlessly with Laravel’s default PHPUnit configuration. No changes to your test classes or Laravel-specific code are needed—just configure the extension in `phpunit.xml`.
- Can I set custom thresholds for slow tests in my CI pipeline?
- Absolutely. Configure thresholds via `phpunit.xml` using environment variables like `PHPUNIT_SLOW_TEST_DETECTOR_MAXIMUM_DURATION` (default: 500ms). Adjust this to match your CI’s performance expectations, e.g., `1000` for 1-second max.
- Does this package support PHPUnit 10.x or 13.x in Laravel?
- Yes, it supports PHPUnit 6.5–13.x, covering all Laravel versions from 5.8 to 10.x. Check your `composer.json` for the PHPUnit version—this package will work as long as it’s within the supported range.
- How do I configure it to fail builds in GitHub Actions if slow tests exceed limits?
- The extension outputs slow tests to `stderr`. In GitHub Actions, capture this output with `phpunit --colors=never 2>&1` and parse it in a step. Use `jq` or shell scripting to check for slow tests and fail the job if thresholds are breached.
- Is there a performance overhead when running tests with this extension?
- No, the overhead is negligible. The extension only measures test durations and doesn’t interfere with test execution logic. You’ll see no impact on test speed, only added visibility into slow tests.
- What if my Laravel project uses PestPHP instead of PHPUnit?
- This package won’t work with PestPHP. PestPHP has its own testing ecosystem, and this extension is PHPUnit-specific. For PestPHP, consider custom scripts or Pest’s built-in timing features.
- Can I integrate this with Laravel Forge or Envoyer for deployment monitoring?
- Yes, the extension’s output is CI/CD-friendly. Use it alongside Forge/Envoyer by parsing slow-test logs in deployment scripts. For example, trigger alerts in Slack or fail deployments if tests exceed thresholds.
- How do I test this package locally before deploying to CI?
- Install it in a dev environment, configure `phpunit.xml`, and run tests locally with `./vendor/bin/phpunit`. Check `stderr` for slow-test reports. Adjust thresholds iteratively to match your local machine’s performance.
- Are there alternatives if I need historical trend analysis for test speeds?
- For trend analysis, pair this package with a custom script or tool like `phpunit-metrics` to log test durations over time. Alternatively, integrate with CI tools like GitHub Actions or Jenkins to archive slow-test reports in artifacts.