Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

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

### Changed

- Started showing output when no tests could be detected with a duration exceeding the maximum duration ([#714]), by [@localheinz]

## [`2.20.0`][2.20.0]

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

[@dantleech]: https://github.com/dantleech
[@HypeMC]: https://github.com/HypeMC
Expand Down
10 changes: 6 additions & 4 deletions src/Reporter/DefaultReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ public function __construct(

public function report(SlowTestList $slowTestList): string
{
if ($slowTestList->isEmpty()) {
return '';
}

return \implode("\n", \iterator_to_array($this->lines($slowTestList)));
}

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

if ($slowTestCount->equals(Count::fromInt(0))) {
yield 'Could not detect any tests where the duration exceeded the maximum duration.';

return;
}

if ($slowTestCount->equals(Count::fromInt(1))) {
yield 'Detected 1 test where the duration exceeded the maximum duration.';
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/Unit/Reporter/DefaultReporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function testReportReturnsEmptyStringWhenSlowTestListIsEmpty()

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

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

/**
Expand Down
Loading