Skip to content

Commit a05623c

Browse files
authored
Merge pull request #93 from johnkary/improve-output-v5
Improve readability of results (rework)
2 parents 14f1d29 + 01c5e98 commit a05623c

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Many factors affect test execution time. A test not properly isolated from varia
88

99
SpeedTrap helps **identify slow tests** but cannot explain **why** those tests are slow. Consider using [Blackfire.io](https://blackfire.io) to profile the test suite to specifically identify slow code.
1010

11-
![Screenshot of terminal using SpeedTrap](https://i.imgur.com/xSpWL4Z.png)
11+
![Screenshot of terminal using SpeedTrap](https://user-images.githubusercontent.com/135607/196077193-ba9e5f95-91ef-4655-88a5-93bb49007a67.png)
1212

1313
## Installation
1414

UPGRADE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ must extend the new `JohnKary\PHPUnit\Extension\SpeedTrap`. There are various
3838
method name changes that may affect your custom subclass. See [PR #83](https://github.com/johnkary/phpunit-speedtrap/pull/83)
3939
for many of the new class has changed.
4040

41+
If you programmatically parse the slowness report text visible when running
42+
`vendor/bin/phpunit`, there have been some text formatting changes in the output:
43+
44+
* The header text has changed
45+
* The footer text has changed
46+
* The slow test output has changed
47+
* Slowness execution time now displays in seconds instead of milliseconds
48+
4149
UPGRADE FROM 3.x to 4.0
4250
=======================
4351

src/SpeedTrap.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ protected function getHiddenCount(): int
195195
*/
196196
protected function renderHeader(): void
197197
{
198-
echo sprintf("\n\nYou should really speed up these slow tests (>%sms)...\n", $this->slowThreshold);
198+
echo sprintf("\n\nThe following tests were detected as slow (>%sms)\n", $this->slowThreshold);
199199
}
200200

201201
/**
@@ -209,8 +209,9 @@ protected function renderBody(): void
209209
for ($i = 1; $i <= $length; ++$i) {
210210
$label = key($slowTests);
211211
$time = array_shift($slowTests);
212+
$seconds = $time / 1000;
212213

213-
echo sprintf(" %s. %sms to run %s\n", $i, $time, $label);
214+
echo sprintf(" %s) %.3fs to run %s\n", $i, $seconds, $label);
214215
}
215216
}
216217

@@ -220,7 +221,7 @@ protected function renderBody(): void
220221
protected function renderFooter(): void
221222
{
222223
if ($hidden = $this->getHiddenCount()) {
223-
printf("...and there %s %s more above your threshold hidden from view\n", $hidden == 1 ? 'is' : 'are', $hidden);
224+
printf("and %s more slow tests hidden from view\n", $hidden);
224225
}
225226
}
226227

tests/SomeSlowTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ public function testLongEndToEndTest()
3333
$this->assertTrue(true);
3434
}
3535

36+
public function testSlowTestsOverOneSecond()
37+
{
38+
$this->extendTime(1300);
39+
40+
$this->assertTrue(true);
41+
}
42+
3643
/**
3744
* @dataProvider provideTime
3845
*/

0 commit comments

Comments
 (0)