Skip to content

Commit 78a7dc2

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

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88

99
For a full diff see [`2.20.0...main`][2.20.0...main].
1010

11+
### Changed
12+
13+
- Started showing output when no tests could be detected with a duration exceeding the maximum duration ([#714]), by [@localheinz]
14+
1115
## [`2.20.0`][2.20.0]
1216

1317
For a full diff see [`2.19.1...2.20.0`][2.19.1...2.20.0].
@@ -423,6 +427,7 @@ For a full diff see [`7afa59c...1.0.0`][7afa59c...1.0.0].
423427
[#651]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/651
424428
[#664]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/664
425429
[#704]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/704
430+
[#714]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/714
426431

427432
[@dantleech]: https://github.com/dantleech
428433
[@HypeMC]: https://github.com/HypeMC

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)