- How do I install johnkary/phpunit-speedtrap in a Laravel project?
- Install it as a Composer dev dependency with composer require --dev johnkary/phpunit-speedtrap, then register it in phpunit.xml as an extension for PHPUnit 9 or a listener for PHPUnit 8 and below. No Laravel service provider, facade, or bootstrap change is required. Confirm your pinned PHPUnit major first, because the package may not install on PHPUnit 10 or 11.
- Does PHPUnit SpeedTrap work with Laravel 11 and PHPUnit 10 or 11?
- Likely not as-is. The last release was in May 2021 and targets PHPUnit 9, while PHPUnit 10 and 11 changed the listener and extension APIs. Composer may block installation on a Laravel 11 project that ships PHPUnit 10 or 11. Plan a maintained fork, a pinned PHPUnit version, or a small internal extension instead.
- How do I configure the slow test threshold for phpunit-speedtrap?
- Set the threshold in milliseconds in the extension or listener configuration block inside phpunit.xml. Start with your current 90th-percentile test duration, often around 300 to 800 ms, so the first report is quiet and credible. Lower the threshold gradually as slow tests are fixed.
- Does phpunit-speedtrap fail the build when a test is slow?
- No. It reports slow tests and slow test suites but does not fail the build by itself. If you need a performance gate, add CI logic that parses the report output or checks per-test durations from JUnit XML. Treat enforcement as a separate phase after the baseline is stable.
- What PHPUnit versions are supported by johnkary/phpunit-speedtrap?
- The package is designed for PHPUnit 9 and can use the older listener mechanism on PHPUnit 8 and below. PHPUnit 10 reshaped the extension APIs and PHPUnit 11 continued that change, so the package is not compatible as-is on those majors. Check composer why-not before planning adoption on newer Laravel projects.
- Why does PHPUnit SpeedTrap show no output in my Laravel test suite?
- The most dangerous failure mode is a silent no-op: if the phpunit.xml extension or listener entry does not match the installed PHPUnit major, the suite can run green and print nothing. Verify the PHPUnit version in composer.lock and confirm the correct XML node is registered. Also check that the config block is in the right place and not being ignored.
- Can I use PHPUnit SpeedTrap with Pest or parallel test execution?
- Pest runs on top of PHPUnit, so compatibility tracks your PHPUnit major rather than Laravel itself; verify it on PHPUnit 9 before relying on it. ParaTest and process isolation can distort or drop per-test durations, so treat the numbers as directional until validated. Do not use distorted timings as a strict CI budget without checking them.
- How do I ignore known slow tests in PHPUnit SpeedTrap?
- The package supports ignore rules for known-slow tests and per-test annotation overrides. Use the ignore list for legitimately heavy integration tests, not for regressions you should fix. Keep the list curated and review it periodically so it does not hide new performance problems.
- Is johnkary/phpunit-speedtrap still maintained, and what are the alternatives?
- It is a single-maintainer project with no release since May 2021, so abandonment risk is medium-to-high. The domain logic is simple, so a maintained fork or a 50 to 100 line internal PHPUnit extension with the same output contract is a realistic alternative. Keep the report format stable so CI parsing survives the swap.
- Does phpunit-speedtrap add overhead to Laravel test runs or production?
- It is a dev-only utility, so nothing is loaded in FPM, queue workers, or production CLI paths. It consumes per-test durations PHPUnit already collects and sorts them after the run, so overhead is minimal. It does not instrument application code, wrap assertions, or touch the database.