Download the PHP package ergebnis/phpunit-slow-test-detector without Composer
On this page you can find all versions of the php package ergebnis/phpunit-slow-test-detector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package phpunit-slow-test-detector
phpunit-slow-test-detector
This project provides a composer
package and a Phar archive with an extension for detecting slow tests in phpunit/phpunit
.
The extension is compatible with the following versions of phpunit/phpunit
:
phpunit/phpunit:^6.5.0
phpunit/phpunit:^7.5.0
phpunit/phpunit:^8.5.19
phpunit/phpunit:^9.0.0
phpunit/phpunit:^10.0.0
phpunit/phpunit:^11.0.0
phpunit/phpunit:^12.0.0
Installation
Installation with composer
Run
to install ergebnis/phpunit-slow-test-detector
as a composer
package.
Installation as Phar
Download phpunit-slow-test-detector.phar
from the latest release.
Usage
Bootstrapping the extension
Before the extension can detect slow tests in phpunit/phpunit
, you need to bootstrap it. The bootstrapping mechanism depends on the version of phpunit/phpunit
you are using.
Bootstrapping the extension as a composer
package
To bootstrap the extension as a composer
package when using
phpunit/phpunit:^6.5.0
adjust your phpunit.xml
configuration file and configure the
To bootstrap the extension as a composer
package when using
phpunit/phpunit:^7.5.0
phpunit/phpunit:^8.5.19
phpunit/phpunit:^9.0.0
adjust your phpunit.xml
configuration file and configure the
extensions
element onphpunit/phpunit:^7.5.0
extensions
element onphpunit/phpunit:^8.5.19
extensions
element onphpunit/phpunit:^9.0.0
To bootstrap the extension as a composer
package when using
phpunit/phpunit:^10.0.0
phpunit/phpunit:^11.0.0
phpunit/phpunit:^12.0.0
adjust your phpunit.xml
configuration file and configure the
extensions
element onphpunit/phpunit:^10.0.0
extensions
element onphpunit/phpunit:^11.0.0
extensions
element onphpunit/phpunit:^12.0.0
Bootstrapping the extension as a PHAR
To bootstrap the extension as a PHAR when using
phpunit/phpunit:^7.5.0
phpunit/phpunit:^8.5.19
phpunit/phpunit:^9.0.0
adjust your phpunit.xml
configuration file and configure the
extensionsDirectory
attribute and theextensions
element onphpunit/phpunit:^7.5.0
extensionsDirectory
attribute and theextensions
element onphpunit/phpunit:^8.5.19
extensionsDirectory
attribute and theextensions
element onphpunit/phpunit:^9.0.0
To bootstrap the extension as a PHAR when using
phpunit/phpunit:^10.0.0
phpunit/phpunit:^11.0.0
phpunit/phpunit:^12.0.0
adjust your phpunit.xml
configuration file and configure the
extensionsDirectory
attribute and theextensions
element onphpunit/phpunit:^10.0.0
extensionsDirectory
attribute and theextensions
element onphpunit/phpunit:^11.0.0
extensionsDirectory
attribute and theextensions
element onphpunit/phpunit:^12.0.0
Configuring the extension
You can configure the extension with the following options in your phpunit.xml
configuration file:
maximum-count
, anint
, the maximum count of slow test that should be reported, defaults to10
maximum-duration
, anint
, the maximum duration in milliseconds for a test before the extension considers it as a slow test, defaults to500
The configuration mechanism depends on the version of phpunit/phpunit
you are using.
Configuring the extension
To configure the extension when using
phpunit/phpunit:^6.5.0
adjust your phpunit.xml
configuration file and configure the
The following example configures the maximum count of slow tests to three, and the maximum duration for all tests to 250 milliseconds:
To configure the extension when using
phpunit/phpunit:^7.5.0
phpunit/phpunit:^8.5.19
phpunit/phpunit:^9.0.0
adjust your phpunit.xml
configuration file and configure the
arguments
element onphpunit/phpunit:^7.5.0
arguments
element onphpunit/phpunit:^8.5.19
arguments
element onphpunit/phpunit:^9.0.0
The following example configures the maximum count of slow tests to three, and the maximum duration for all tests to 250 milliseconds:
To configure the extension when using
phpunit/phpunit:^10.0.0
phpunit/phpunit:^11.0.0
phpunit/phpunit:^12.0.0
adjust your phpunit.xml
configuration file and configure one or more
parameter
elements onphpunit/phpunit:^10.0.0
parameter
elements onphpunit/phpunit:^11.0.0
parameter
elements onphpunit/phpunit:^12.0.0
The following example configures the maximum count of slow tests to three, and the maximum duration for all tests to 250 milliseconds:
Configuring the maximum duration per test case
You can configure the maximum duration for a single test case with
- an
Attribute\MaximumDuration
attribute when usingphpunit/phpunit:^10.0.0
phpunit/phpunit:^11.0.0
phpunit/phpunit:^12.0.0
- a
@maximumDuration
annotation in the DocBlock when usingphpunit/phpunit:^6.5.0
phpunit/phpunit:^7.5.0
phpunit/phpunit:^8.5.19
phpunit/phpunit:^9.0.0
- a
@slowThreshold
annotation in the DocBlock when usingphpunit/phpunit:^6.5.0
phpunit/phpunit:^7.5.0
phpunit/phpunit:^8.5.19
phpunit/phpunit:^9.0.0
The following example configures the maximum durations for single test cases to 5,000 ms, 4,000 ms, and 3,000 ms:
[!NOTE]
Support for the
@slowThreshold
annotation exists only to help you move fromjohnkary/phpunit-speedtrap
. It will be deprecated and removed in the near future.
Running tests
When you have bootstrapped the extension, you can run your tests as usually:
When the extension has detected slow tests, it will report them:
Understanding measured test durations
Understanding measured test durations when using the hooks event system
When using
phpunit/phpunit:^6.5.0
phpunit/phpunit:^7.5.0
phpunit/phpunit:^8.5.19
phpunit/phpunit:^9.0.0
the extension uses the hooks event system of phpunit/phpunit
, and measures the duration that is passed to the PHPUnit\Runner\AfterTestHook
. This is the duration of invoking PHPUnit\Framework\TestCase::runBare()
and more.
[!NOTE] Because of this behavior, the measured test durations can and will vary depending on the order in which
phpunit/phpunit
executes tests.
Understanding measured test durations when using the new event system
When using
phpunit/phpunit:^10.0.0
phpunit/phpunit:^11.0.0
phpunit/phpunit:^12.0.0
the extension uses the new event system of phpunit/phpunit
, and measures the duration between the points in time when the PHPUnit\Event\Test\PreparationStarted
and PHPUnit\Event\Test\Finished
are emitted.
Changelog
The maintainers of this project record notable changes to this project in a changelog.
Contributing
The maintainers of this project suggest following the contribution guide.
Code of Conduct
The maintainers of this project ask contributors to follow the code of conduct.
General Support Policy
The maintainers of this project provide limited support.
You can support the maintenance of this project by sponsoring @localheinz or requesting an invoice for services related to this project.
PHP Version Support Policy
This project supports PHP versions with active and security support.
The maintainers of this project add support for a PHP version following its initial release and drop support for a PHP version when it has reached the end of security support.
Security Policy
This project has a security policy.
License
This project uses the MIT license.
Credits
This package is inspired by johnkary/phpunit-speedtrap
, originally licensed under MIT by John Kary.
Social
Follow @localheinz and @ergebnis on Twitter.
All versions of phpunit-slow-test-detector with dependencies
phpunit/phpunit Version ^6.5.0 || ^7.5.0 || ^8.5.19 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0