@@ -20,27 +20,15 @@ SpeedTrap is installed using [Composer](http://getcomposer.org). Add it as a `re
20
20
## Usage
21
21
22
22
Enable with all defaults by adding the following code to your project's ` phpunit.xml ` file:
23
-
24
- If you are using PHPUnit 8 or above, and phpunit-speedtrap >= 4.0.0, you should register the listener like this:
25
23
26
24
``` xml
27
25
<phpunit bootstrap =" vendor/autoload.php" >
28
26
...
29
27
<extensions >
30
- <extension class =" JohnKary\PHPUnit\Listener\SpeedTrapListener " />
28
+ <extension class =" JohnKary\PHPUnit\Extension\SpeedTrap " />
31
29
</extensions >
32
30
</phpunit >
33
31
```
34
- Otherwise you can add the following:
35
-
36
- ``` xml
37
- <phpunit bootstrap =" vendor/autoload.php" >
38
- ...
39
- <listeners >
40
- <listener class =" JohnKary\PHPUnit\Listener\SpeedTrapListener" />
41
- </listeners >
42
- </phpunit >
43
- ```
44
32
45
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.
46
34
@@ -58,7 +46,7 @@ Each parameter is set in `phpunit.xml`:
58
46
<!-- ... other suite configuration here ... -->
59
47
60
48
<extensions >
61
- <extension class =" JohnKary\PHPUnit\Listener\SpeedTrapListener " >
49
+ <extension class =" JohnKary\PHPUnit\Extension\SpeedTrap " >
62
50
<arguments >
63
51
<array >
64
52
<element key =" slowThreshold" >
@@ -95,15 +83,15 @@ class SomeTestCase extends PHPUnit\Framework\TestCase
95
83
96
84
## Disable slowness profiling using an environment variable
97
85
98
- SpeedTrapListener profiles for slow tests when enabled in phpunit.xml. But using an environment variable named ` PHPUNIT_SPEEDTRAP ` can enable or disable the listener.
86
+ SpeedTrap profiles for slow tests when enabled in phpunit.xml. But using an environment variable named ` PHPUNIT_SPEEDTRAP ` can enable or disable the extension:
99
87
100
88
$ PHPUNIT_SPEEDTRAP="disabled" ./vendor/bin/phpunit
101
89
102
90
#### Use case: Disable profiling in development, but profile with Travis CI
103
91
104
92
Travis CI is popular for running tests in the cloud after pushing new code to a repository.
105
93
106
- Step 1) Enable SpeedTrapListener in phpunit.xml, but set ` PHPUNIT_SPEEDTRAP="disabled" ` to disable profiling when running tests.
94
+ Step 1) Enable SpeedTrap in phpunit.xml, but set ` PHPUNIT_SPEEDTRAP="disabled" ` to disable profiling when running tests.
107
95
108
96
``` xml
109
97
<phpunit bootstrap =" vendor/autoload.php" >
@@ -112,9 +100,9 @@ Step 1) Enable SpeedTrapListener in phpunit.xml, but set `PHPUNIT_SPEEDTRAP="dis
112
100
<env name =" PHPUNIT_SPEEDTRAP" value =" disabled" />
113
101
</php >
114
102
115
- <listeners >
116
- <listener class =" JohnKary\PHPUnit\Listener\SpeedTrapListener " />
117
- </listeners >
103
+ <extensions >
104
+ <extension class =" JohnKary\PHPUnit\Extension\SpeedTrap " />
105
+ </extensions >
118
106
</phpunit >
119
107
```
120
108
@@ -136,14 +124,14 @@ Step 3) View the Travis CI build output and read the slowness report printed in
136
124
137
125
#### Use case: Enable profiling in development, but disable with Travis CI
138
126
139
- Step 1) Enable SpeedTrapListener in phpunit.xml. The slowness report will output during all test suite executions.
127
+ Step 1) Enable SpeedTrap in phpunit.xml. The slowness report will output during all test suite executions.
140
128
141
129
` ` ` xml
142
130
<phpunit bootstrap="vendor/autoload.php">
143
131
...
144
- <listeners >
145
- <listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener " />
146
- </listeners >
132
+ <extensions >
133
+ <extension class="JohnKary\PHPUnit\Extension\SpeedTrap " />
134
+ </extensions >
147
135
</phpunit>
148
136
```
149
137
@@ -161,11 +149,11 @@ env:
161
149
162
150
Step 3) View the Travis CI build output and confirm the slowness report is not printed in the console.
163
151
164
- #### Use case: Only enable SpeedTrapListener on demand via command-line
152
+ #### Use case: Only enable SpeedTrap on demand via command-line
165
153
166
154
Useful when you only want to profile slow tests once in a while.
167
155
168
- Step 1) Setup phpunit.xml to enable SpeedTrapListener , but disable slowness profiling by setting ` PHPUNIT_SPEEDTRAP="disabled"` like this:
156
+ Step 1) Setup phpunit.xml to enable SpeedTrap , but disable slowness profiling by setting ` PHPUNIT_SPEEDTRAP="disabled"` like this:
169
157
170
158
` ` ` xml
171
159
<phpunit bootstrap="vendor/autoload.php">
@@ -174,9 +162,9 @@ Step 1) Setup phpunit.xml to enable SpeedTrapListener, but disable slowness prof
174
162
<env name="PHPUNIT_SPEEDTRAP" value="disabled" />
175
163
</php>
176
164
177
- <listeners >
178
- <listener class="JohnKary\P HPUnit\L istener \S peedTrapListener " />
179
- </listeners >
165
+ <extensions >
166
+ <extension class="JohnKary\P HPUnit\E xtension \S peedTrap " />
167
+ </extensions >
180
168
</phpunit>
181
169
` ` `
182
170
0 commit comments