From 171367927f5c56f0f66bf9b04724ed2227f9a923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Mon, 25 Jan 2021 14:19:54 +0100 Subject: [PATCH] Fix: Account for a single slow test in report --- src/Reporter/DefaultReporter.php | 7 ++++ test/Unit/Reporter/DefaultReporterTest.php | 44 +++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/Reporter/DefaultReporter.php b/src/Reporter/DefaultReporter.php index 4c1c1aa3..d7358498 100644 --- a/src/Reporter/DefaultReporter.php +++ b/src/Reporter/DefaultReporter.php @@ -76,6 +76,13 @@ private function header(SlowTest ...$slowTests): string $formattedMaximumDuration = $this->durationFormatter->format($this->maximumDuration); + if (1 === $count) { + return <<report(...$slowTests); + + $expected = <<<'TXT' +Detected 1 test that took longer than 100 ms. + +7,890 ms: Ergebnis\PHPUnit\SlowTestDetector\Test\Example\SleeperTest::foo with data set #123 +TXT; + + self::assertSame($expected, $report); + } + + public function testReportReturnsReportWhenTheNumberOfSlowTestsIsSmallerThanTheMaximumCountAndGreaterThanOne(): void { $faker = self::faker();