Skip to content

Commit ce7407b

Browse files
committed
Enhancement: Show output when no tests could be detected with a duration exceeding the maximum duration
1 parent 339484c commit ce7407b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/Reporter/DefaultReporter.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ public function __construct(
4343

4444
public function report(SlowTestList $slowTestList): string
4545
{
46-
if ($slowTestList->isEmpty()) {
47-
return '';
48-
}
49-
5046
return \implode("\n", \iterator_to_array($this->lines($slowTestList)));
5147
}
5248

@@ -57,6 +53,12 @@ private function lines(SlowTestList $slowTestList): \Generator
5753
{
5854
$slowTestCount = $slowTestList->count();
5955

56+
if ($slowTestCount->equals(Count::fromInt(0))) {
57+
yield 'Could not detect any tests where the duration exceeded the maximum duration.';
58+
59+
return;
60+
}
61+
6062
if ($slowTestCount->equals(Count::fromInt(1))) {
6163
yield 'Detected 1 test where the duration exceeded the maximum duration.';
6264
} else {

test/Unit/Reporter/DefaultReporterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function testReportReturnsEmptyStringWhenSlowTestListIsEmpty()
5757

5858
$report = $reporter->report($slowTestList);
5959

60-
self::assertSame('', $report);
60+
self::assertSame('Could not detect any tests where the duration exceeded the maximum duration.', $report);
6161
}
6262

6363
/**

0 commit comments

Comments
 (0)