Skip to content

Commit 79589d9

Browse files
committed
Use test assertion for minimum runtime
Avoids error that the test did not perform any assertions.
1 parent fcba1f0 commit 79589d9

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/AsyncTestCase.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,14 @@ final public function runAsyncTest(...$args)
7070
throw $exception;
7171
}
7272

73-
$actualRuntime = (int) (\round(\microtime(true) - $start, self::RUNTIME_PRECISION) * 1000);
74-
if ($this->minimumRuntime > $actualRuntime) {
73+
if ($this->minimumRuntime > 0) {
74+
$actualRuntime = (int) (\round(\microtime(true) - $start, self::RUNTIME_PRECISION) * 1000);
7575
$msg = 'Expected test to take at least %dms but instead took %dms';
76-
$this->fail(\sprintf($msg, $this->minimumRuntime, $actualRuntime));
76+
$this->assertGreaterThanOrEqual(
77+
$this->minimumRuntime,
78+
$actualRuntime,
79+
\sprintf($msg, $this->minimumRuntime, $actualRuntime)
80+
);
7781
}
7882

7983
return $returnValue;
@@ -86,6 +90,10 @@ final public function runAsyncTest(...$args)
8690
*/
8791
final protected function setMinimumRuntime(int $runtime)
8892
{
93+
if ($runtime < 1) {
94+
throw new \Error('Minimum runtime must be at least 1ms');
95+
}
96+
8997
$this->minimumRuntime = $runtime;
9098
}
9199

0 commit comments

Comments
 (0)