Skip to content

Commit 386f65b

Browse files
committed
Slowness execution time output in seconds instead of milliseconds
Slow tests often run for over 1 second. The output of 1000 milliseconds or more can be harder to read the longer the test runs. Using seconds inserts a decimal to make output easier to read for humans. For example, a slow test running for 12432 milliseconds displays as 12.432 seconds
1 parent 14f1d29 commit 386f65b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/SpeedTrap.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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. %ss to run %s\n", $i, $seconds, $label);
214215
}
215216
}
216217

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)