You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -12,7 +12,7 @@ SpeedTrap helps **identify slow tests** but cannot explain **why** those tests a
12
12
13
13
## Installation
14
14
15
-
SpeedTrap is installable via[Composer](http://getcomposer.org) and should be added as a `require-dev` dependency:
15
+
SpeedTrap is installed using[Composer](http://getcomposer.org). Add it as a `require-dev` dependency:
16
16
17
17
composer require --dev johnkary/phpunit-speedtrap
18
18
@@ -30,16 +30,16 @@ Enable with all defaults by adding the following code to your project's `phpunit
30
30
</phpunit>
31
31
```
32
32
33
-
Now run the test suite as normal. If one or more test executions exceed the slowness threshold (500ms by default), SpeedTrap will report on those tests in the console after all tests have completed.
33
+
Now run the test suite. If one or more test executions exceed the slowness threshold (500ms by default), SpeedTrap will report on those tests in the console after all tests have completed.
34
34
35
-
## Configuration
35
+
## Config Parameters
36
36
37
-
SpeedTrap has two configurable parameters:
37
+
SpeedTrap also supports these parameters:
38
38
39
-
***slowThreshold** - Number of milliseconds a test takes to execute before being considered "slow" (Default: 500ms)
39
+
***slowThreshold** - Number of milliseconds when a test is considered "slow" (Default: 500ms)
40
40
***reportLength** - Number of slow tests included in the report (Default: 10 tests)
41
41
42
-
These configuration parameters are set in `phpunit.xml` when adding the listener:
42
+
Each parameter is set in `phpunit.xml`:
43
43
44
44
```xml
45
45
<phpunitbootstrap="vendor/autoload.php">
@@ -62,13 +62,11 @@ These configuration parameters are set in `phpunit.xml` when adding the listener
62
62
</phpunit>
63
63
```
64
64
65
-
This allows customizing what the project considers a "slow" test and how many are reported on to project maintainers.
66
-
67
65
## Custom slowness threshold per-test case
68
66
69
67
Some projects have a few complex tests that take a long time to run. It is possible to set a different slowness threshold for individual test cases.
70
68
71
-
Use the annotation `@slowThreshold`to set a custom slowness threshold for single test cases. This number may be higher or lower than the default threshold and will be used in place of the default threshold for that specific test.
69
+
The annotation `@slowThreshold`can set a custom slowness threshold for each test case. This number may be higher or lower than the default threshold and is used instead of the default threshold for that specific test.
72
70
73
71
```php
74
72
class SomeTestCase extends PHPUnit\Framework\TestCase
@@ -83,9 +81,102 @@ class SomeTestCase extends PHPUnit\Framework\TestCase
83
81
}
84
82
```
85
83
84
+
## Disable slowness profiling using an environment variable
85
+
86
+
SpeedTrapListener profiles for slow tests when enabled in phpunit.xml. But using an environment variable named `PHPUNIT_SPEEDTRAP` can enable or disable the listener.
Step 2) When executing `phpunit` from the command-line, enable slowness profiling only for this run by passing the environment variable `PHPUNIT_SPEEDTRAP="enabled"` like this:
172
+
173
+
```bash
174
+
$ PHPUNIT_SPEEDTRAP=enabled ./vendor/bin/phpunit
175
+
```
176
+
86
177
## Inspiration
87
178
88
-
This project was inspired by [RSpec's](https://github.com/rspec/rspec)`--profile` option that displays feedback about slow tests.
179
+
SpeedTrap was inspired by [RSpec's](https://github.com/rspec/rspec) `--profile` option that displays feedback about slow tests.
0 commit comments