diff --git a/README.md b/README.md index 0b9de1ef..449cff45 100644 --- a/README.md +++ b/README.md @@ -398,18 +398,18 @@ Random Seed: 1676103726 ............. 13 / 13 (100%) -Detected 11 tests where the duration exceeded the maximum duration. - - 1. 1.604 s (500 ms) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #10 (1600) - 2. 1.505 s (500 ms) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #9 (1500) - 3. 1.403 s (500 ms) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #8 (1400) - 4. 1.303 s (500 ms) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #7 (1300) - 5. 1.205 s (500 ms) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #6 (1200) - 6. 1.103 s (500 ms) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #5 (1100) - 7. 1.005 s (500 ms) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #4 (1000) - 8. 905 ms (500 ms) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #3 (900) - 9. 805 ms (500 ms) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #2 (800) -10. 705 ms (500 ms) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #1 (700) +Detected 11 tests where the duration exceeded the maximum duration (500 ms). + + 1. 1.604 s Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #10 (1600) + 2. 1.505 s Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #9 (1500) + 3. 1.403 s Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #8 (1400) + 4. 1.303 s Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #7 (1300) + 5. 1.205 s Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #6 (1200) + 6. 1.103 s Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #5 (1100) + 7. 1.005 s Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #4 (1000) + 8. 905 ms Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #3 (900) + 9. 805 ms Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #2 (800) +10. 705 ms Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Default\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #1 (700) There is 1 additional slow test that is not listed here. diff --git a/src/Reporter/DefaultReporter.php b/src/Reporter/DefaultReporter.php index e14288f4..6997a971 100644 --- a/src/Reporter/DefaultReporter.php +++ b/src/Reporter/DefaultReporter.php @@ -83,15 +83,18 @@ private function header(SlowTest ...$slowTests): string { $count = \count($slowTests); + $durationFormatter = $this->durationFormatter; + $formattedMaximumDuration = $durationFormatter->format($this->maximumDuration); + if (1 === $count) { return <<format($slowestTest->duration())); $maximumDurationWidth = \strlen($durationFormatter->format($longestMaximumDuration)); - $items = \array_map(static function (int $number, SlowTest $slowTest) use ($numberWidth, $durationFormatter, $durationWidth, $maximumDurationWidth): string { + $formattedMaximumGlobalDuration = \str_pad( + $durationFormatter->format($this->maximumDuration), + $maximumDurationWidth, + ' ', + \STR_PAD_LEFT + ); + + $items = \array_map(static function (int $number, SlowTest $slowTest) use ($numberWidth, $durationFormatter, $durationWidth, $formattedMaximumGlobalDuration, $maximumDurationWidth): string { $formattedNumber = \str_pad( (string) $number, $numberWidth, @@ -149,20 +159,21 @@ static function (Duration $maximumDuration, SlowTest $slowTest): Duration { \STR_PAD_LEFT ); - $formattedMaximumDuration = \sprintf( - '(%s)', - \str_pad( - $durationFormatter->format($slowTest->maximumDuration()), - $maximumDurationWidth, - ' ', - \STR_PAD_LEFT - ) + $formattedMaximumDuration = \str_pad( + $durationFormatter->format($slowTest->maximumDuration()), + $maximumDurationWidth, + ' ', + \STR_PAD_LEFT ); + $formattedMaximumDurationIfNotGlobal = $formattedMaximumDuration === $formattedMaximumGlobalDuration + ? '' + : \sprintf(' (%s)', $formattedMaximumDuration); + $testDescription = $slowTest->testDescription()->toString(); return << [ <<<'TXT' -Detected 1 test where the duration exceeded the maximum duration. +Detected 1 test where the duration exceeded the maximum duration (500 ms). 1. 300 ms (100 ms) FooTest::test TXT @@ -101,7 +101,7 @@ public static function provideExpectedReportMaximumDurationMaximumCountAndSlowTe ], 'header-plural' => [ <<<'TXT' -Detected 2 tests where the duration exceeded the maximum duration. +Detected 2 tests where the duration exceeded the maximum duration (500 ms). 1. 300 ms (100 ms) FooTest::test 2. 275 ms (100 ms) BarTest::test @@ -126,7 +126,7 @@ public static function provideExpectedReportMaximumDurationMaximumCountAndSlowTe ], 'list-sorted' => [ <<<'TXT' -Detected 3 tests where the duration exceeded the maximum duration. +Detected 3 tests where the duration exceeded the maximum duration (500 ms). 1. 300 ms (100 ms) FooTest::test 2. 275 ms (100 ms) BarTest::test @@ -158,7 +158,7 @@ public static function provideExpectedReportMaximumDurationMaximumCountAndSlowTe ], 'list-unsorted' => [ <<<'TXT' -Detected 3 tests where the duration exceeded the maximum duration. +Detected 3 tests where the duration exceeded the maximum duration (500 ms). 1. 300 ms (100 ms) FooTest::test 2. 275 ms (100 ms) BarTest::test @@ -190,7 +190,7 @@ public static function provideExpectedReportMaximumDurationMaximumCountAndSlowTe ], 'list-different-maximum-duration' => [ <<<'TXT' -Detected 10 tests where the duration exceeded the maximum duration. +Detected 10 tests where the duration exceeded the maximum duration (500 ms). 1. 20:50.000 (16:40.000) FooTest::test 2. 9:35.000 ( 8:20.000) BarTest::test @@ -271,7 +271,7 @@ public static function provideExpectedReportMaximumDurationMaximumCountAndSlowTe ], 'footer-singular' => [ <<<'TXT' -Detected 2 tests where the duration exceeded the maximum duration. +Detected 2 tests where the duration exceeded the maximum duration (500 ms). 1. 300 ms (100 ms) FooTest::test @@ -297,7 +297,7 @@ public static function provideExpectedReportMaximumDurationMaximumCountAndSlowTe ], 'footer-plural' => [ <<<'TXT' -Detected 3 tests where the duration exceeded the maximum duration. +Detected 3 tests where the duration exceeded the maximum duration (500 ms). 1. 300 ms (100 ms) FooTest::test