From f7ca8cf15f24cbb0da5dbefd5bcdf259ba16d815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 11 Feb 2025 12:42:49 +0100 Subject: [PATCH 1/2] Improve UX, show duration in/with SI units --- README.md | 22 +++++------ src/Formatter/DefaultDurationFormatter.php | 11 +++++- .../Configuration/Defaults/test.phpt | 20 +++++----- .../Configuration/MaximumCount/test.phpt | 6 +-- .../Configuration/MaximumDuration/test.phpt | 20 +++++----- .../Version06/TestCase/Bare/test.phpt | 4 +- .../Version06/TestCase/Combination/test.phpt | 6 +-- .../TestCase/WithAfterAnnotation/test.phpt | 6 +-- .../WithAfterClassAnnotation/test.phpt | 4 +- .../WithAssertPostConditions/test.phpt | 6 +-- .../WithAssertPreConditions/test.phpt | 6 +-- .../TestCase/WithBeforeAnnotation/test.phpt | 6 +-- .../WithBeforeClassAnnotation/test.phpt | 4 +- .../TestCase/WithDataProvider/test.phpt | 4 +- .../Version06/TestCase/WithSetUp/test.phpt | 6 +-- .../TestCase/WithSetUpBeforeClass/test.phpt | 4 +- .../Version06/TestCase/WithTearDown/test.phpt | 6 +-- .../TestCase/WithTearDownAfterClass/test.phpt | 4 +- .../test.phpt | 2 +- .../WithMaximumDurationAnnotation/test.phpt | 4 +- .../test.phpt | 8 ++-- .../test.phpt | 2 +- .../WithSlowThresholdAnnotation/test.phpt | 4 +- .../Configuration/Defaults/test.phpt | 20 +++++----- .../Configuration/MaximumCount/test.phpt | 6 +-- .../Configuration/MaximumDuration/test.phpt | 20 +++++----- .../Version07/TestCase/Bare/test.phpt | 4 +- .../Version07/TestCase/Combination/test.phpt | 6 +-- .../TestCase/WithAfterAnnotation/test.phpt | 6 +-- .../WithAfterClassAnnotation/test.phpt | 4 +- .../WithAssertPostConditions/test.phpt | 6 +-- .../WithAssertPreConditions/test.phpt | 6 +-- .../TestCase/WithBeforeAnnotation/test.phpt | 6 +-- .../WithBeforeClassAnnotation/test.phpt | 4 +- .../TestCase/WithDataProvider/test.phpt | 4 +- .../Version07/TestCase/WithSetUp/test.phpt | 6 +-- .../TestCase/WithSetUpBeforeClass/test.phpt | 4 +- .../Version07/TestCase/WithTearDown/test.phpt | 6 +-- .../TestCase/WithTearDownAfterClass/test.phpt | 4 +- .../test.phpt | 2 +- .../WithMaximumDurationAnnotation/test.phpt | 4 +- .../test.phpt | 8 ++-- .../test.phpt | 2 +- .../WithSlowThresholdAnnotation/test.phpt | 4 +- .../Configuration/Defaults/test.phpt | 20 +++++----- .../Configuration/MaximumCount/test.phpt | 6 +-- .../Configuration/MaximumDuration/test.phpt | 20 +++++----- .../Version08/TestCase/Bare/test.phpt | 4 +- .../Version08/TestCase/Combination/test.phpt | 6 +-- .../TestCase/WithAfterAnnotation/test.phpt | 6 +-- .../WithAfterClassAnnotation/test.phpt | 4 +- .../WithAssertPostConditions/test.phpt | 6 +-- .../WithAssertPreConditions/test.phpt | 6 +-- .../TestCase/WithBeforeAnnotation/test.phpt | 6 +-- .../WithBeforeClassAnnotation/test.phpt | 4 +- .../TestCase/WithDataProvider/test.phpt | 4 +- .../Version08/TestCase/WithSetUp/test.phpt | 6 +-- .../TestCase/WithSetUpBeforeClass/test.phpt | 4 +- .../Version08/TestCase/WithTearDown/test.phpt | 6 +-- .../TestCase/WithTearDownAfterClass/test.phpt | 4 +- .../test.phpt | 2 +- .../WithMaximumDurationAnnotation/test.phpt | 4 +- .../test.phpt | 8 ++-- .../test.phpt | 2 +- .../WithSlowThresholdAnnotation/test.phpt | 4 +- .../Configuration/Defaults/test.phpt | 20 +++++----- .../Configuration/MaximumCount/test.phpt | 6 +-- .../Configuration/MaximumDuration/test.phpt | 20 +++++----- .../Version09/TestCase/Bare/test.phpt | 4 +- .../Version09/TestCase/Combination/test.phpt | 6 +-- .../TestCase/WithAfterAnnotation/test.phpt | 6 +-- .../WithAfterClassAnnotation/test.phpt | 4 +- .../WithAssertPostConditions/test.phpt | 6 +-- .../WithAssertPreConditions/test.phpt | 6 +-- .../TestCase/WithBeforeAnnotation/test.phpt | 6 +-- .../WithBeforeClassAnnotation/test.phpt | 4 +- .../TestCase/WithDataProvider/test.phpt | 4 +- .../Version09/TestCase/WithSetUp/test.phpt | 6 +-- .../TestCase/WithSetUpBeforeClass/test.phpt | 4 +- .../Version09/TestCase/WithTearDown/test.phpt | 6 +-- .../TestCase/WithTearDownAfterClass/test.phpt | 4 +- .../test.phpt | 2 +- .../WithMaximumDurationAnnotation/test.phpt | 4 +- .../test.phpt | 8 ++-- .../test.phpt | 2 +- .../WithSlowThresholdAnnotation/test.phpt | 4 +- .../Configuration/Defaults/test.phpt | 20 +++++----- .../Configuration/MaximumCount/test.phpt | 6 +-- .../Configuration/MaximumDuration/test.phpt | 20 +++++----- .../Version10/TestCase/Bare/test.phpt | 4 +- .../Version10/TestCase/Combination/test.phpt | 6 +-- .../TestCase/WithAfterAnnotation/test.phpt | 6 +-- .../TestCase/WithAfterAttribute/test.phpt | 6 +-- .../WithAfterClassAnnotation/test.phpt | 4 +- .../WithAfterClassAttribute/test.phpt | 4 +- .../WithAssertPostConditions/test.phpt | 6 +-- .../WithAssertPreConditions/test.phpt | 6 +-- .../TestCase/WithBeforeAnnotation/test.phpt | 6 +-- .../TestCase/WithBeforeAttribute/test.phpt | 6 +-- .../WithBeforeClassAnnotation/test.phpt | 4 +- .../WithBeforeClassAttribute/test.phpt | 4 +- .../TestCase/WithDataProvider/test.phpt | 4 +- .../Version10/TestCase/WithSetUp/test.phpt | 6 +-- .../TestCase/WithSetUpBeforeClass/test.phpt | 4 +- .../Version10/TestCase/WithTearDown/test.phpt | 6 +-- .../TestCase/WithTearDownAfterClass/test.phpt | 4 +- .../test.phpt | 2 +- .../WithMaximumDurationAnnotation/test.phpt | 4 +- .../WithMaximumDurationAttribute/test.phpt | 2 +- .../test.phpt | 8 ++-- .../test.phpt | 8 ++-- .../test.phpt | 2 +- .../WithSlowThresholdAnnotation/test.phpt | 4 +- .../Configuration/Defaults/test.phpt | 20 +++++----- .../Configuration/MaximumCount/test.phpt | 6 +-- .../Configuration/MaximumDuration/test.phpt | 20 +++++----- .../Version11/TestCase/Bare/test.phpt | 4 +- .../Version11/TestCase/Combination/test.phpt | 6 +-- .../TestCase/WithAfterAttribute/test.phpt | 6 +-- .../WithAfterClassAttribute/test.phpt | 4 +- .../WithAssertPostConditions/test.phpt | 6 +-- .../WithAssertPreConditions/test.phpt | 6 +-- .../TestCase/WithBeforeAttribute/test.phpt | 6 +-- .../WithBeforeClassAttribute/test.phpt | 4 +- .../TestCase/WithDataProvider/test.phpt | 4 +- .../Version11/TestCase/WithSetUp/test.phpt | 6 +-- .../TestCase/WithSetUpBeforeClass/test.phpt | 4 +- .../Version11/TestCase/WithTearDown/test.phpt | 6 +-- .../TestCase/WithTearDownAfterClass/test.phpt | 4 +- .../test.phpt | 2 +- .../WithMaximumDurationAnnotation/test.phpt | 4 +- .../WithMaximumDurationAttribute/test.phpt | 2 +- .../test.phpt | 8 ++-- .../test.phpt | 2 +- .../WithSlowThresholdAnnotation/test.phpt | 4 +- .../Configuration/Defaults/test.phpt | 20 +++++----- .../Configuration/MaximumCount/test.phpt | 6 +-- .../Configuration/MaximumDuration/test.phpt | 20 +++++----- .../Version12/TestCase/Bare/test.phpt | 4 +- .../Version12/TestCase/Combination/test.phpt | 6 +-- .../TestCase/WithAfterAttribute/test.phpt | 6 +-- .../WithAfterClassAttribute/test.phpt | 4 +- .../WithAssertPostConditions/test.phpt | 6 +-- .../WithAssertPreConditions/test.phpt | 6 +-- .../TestCase/WithBeforeAttribute/test.phpt | 6 +-- .../WithBeforeClassAttribute/test.phpt | 4 +- .../TestCase/WithDataProvider/test.phpt | 4 +- .../Version12/TestCase/WithSetUp/test.phpt | 6 +-- .../TestCase/WithSetUpBeforeClass/test.phpt | 4 +- .../Version12/TestCase/WithTearDown/test.phpt | 6 +-- .../TestCase/WithTearDownAfterClass/test.phpt | 4 +- .../WithMaximumDurationAttribute/test.phpt | 2 +- .../test.phpt | 8 ++-- .../DefaultDurationFormatterTest.php | 8 ++-- test/Unit/Reporter/DefaultReporterTest.php | 38 +++++++++---------- 155 files changed, 516 insertions(+), 509 deletions(-) diff --git a/README.md b/README.md index bb32596d..0b9de1ef 100644 --- a/README.md +++ b/README.md @@ -339,7 +339,7 @@ You can configure the maximum duration for a single test case with - `phpunit/phpunit:^8.5.19` - `phpunit/phpunit:^9.0.0` -The following example configures the maximum durations for single test cases to 5.000 ms, 4.000 ms, and 3.000 ms: +The following example configures the maximum durations for single test cases to 5.000 s, 4.000 s, and 3.000 s: ```php [ Duration::fromSecondsAndNanoseconds( 0, 123999000 ), - '0.123', + '123 ms', ], 'seconds-digits-one' => [ Duration::fromSecondsAndNanoseconds( 1, 234456789 ), - '1.234', + '1.234 s', ], 'seconds-digits-two' => [ Duration::fromSecondsAndNanoseconds( 12, 345678912 ), - '12.345', + '12.345 s', ], 'minutes-digits-one' => [ Duration::fromSecondsAndNanoseconds( diff --git a/test/Unit/Reporter/DefaultReporterTest.php b/test/Unit/Reporter/DefaultReporterTest.php index c1a14d0b..bb7394c1 100644 --- a/test/Unit/Reporter/DefaultReporterTest.php +++ b/test/Unit/Reporter/DefaultReporterTest.php @@ -85,7 +85,7 @@ public static function provideExpectedReportMaximumDurationMaximumCountAndSlowTe <<<'TXT' Detected 1 test where the duration exceeded the maximum duration. -1. 0.300 (0.100) FooTest::test +1. 300 ms (100 ms) FooTest::test TXT , Duration::fromMilliseconds(500), @@ -103,8 +103,8 @@ public static function provideExpectedReportMaximumDurationMaximumCountAndSlowTe <<<'TXT' Detected 2 tests where the duration exceeded the maximum duration. -1. 0.300 (0.100) FooTest::test -2. 0.275 (0.100) BarTest::test +1. 300 ms (100 ms) FooTest::test +2. 275 ms (100 ms) BarTest::test TXT , Duration::fromMilliseconds(500), @@ -128,9 +128,9 @@ public static function provideExpectedReportMaximumDurationMaximumCountAndSlowTe <<<'TXT' Detected 3 tests where the duration exceeded the maximum duration. -1. 0.300 (0.100) FooTest::test -2. 0.275 (0.100) BarTest::test -3. 0.250 (0.100) BazTest::test +1. 300 ms (100 ms) FooTest::test +2. 275 ms (100 ms) BarTest::test +3. 250 ms (100 ms) BazTest::test TXT , Duration::fromMilliseconds(500), @@ -160,9 +160,9 @@ public static function provideExpectedReportMaximumDurationMaximumCountAndSlowTe <<<'TXT' Detected 3 tests where the duration exceeded the maximum duration. -1. 0.300 (0.100) FooTest::test -2. 0.275 (0.100) BarTest::test -3. 0.250 (0.100) BazTest::test +1. 300 ms (100 ms) FooTest::test +2. 275 ms (100 ms) BarTest::test +3. 250 ms (100 ms) BazTest::test TXT , Duration::fromMilliseconds(500), @@ -194,14 +194,14 @@ public static function provideExpectedReportMaximumDurationMaximumCountAndSlowTe 1. 20:50.000 (16:40.000) FooTest::test 2. 9:35.000 ( 8:20.000) BarTest::test - 3. 0.250 ( 0.100) BazTest::test - 4. 0.200 ( 0.100) QuxTest::test - 5. 0.160 ( 0.100) QuuxTest::test - 6. 0.150 ( 0.100) CorgeTest::test - 7. 0.140 ( 0.100) GraultTest::test - 8. 0.130 ( 0.100) GarplyTest::test - 9. 0.120 ( 0.100) WaldoTest::test -10. 0.110 ( 0.100) FredTest::test + 3. 250 ms ( 100 ms) BazTest::test + 4. 200 ms ( 100 ms) QuxTest::test + 5. 160 ms ( 100 ms) QuuxTest::test + 6. 150 ms ( 100 ms) CorgeTest::test + 7. 140 ms ( 100 ms) GraultTest::test + 8. 130 ms ( 100 ms) GarplyTest::test + 9. 120 ms ( 100 ms) WaldoTest::test +10. 110 ms ( 100 ms) FredTest::test TXT , Duration::fromMilliseconds(500), @@ -273,7 +273,7 @@ public static function provideExpectedReportMaximumDurationMaximumCountAndSlowTe <<<'TXT' Detected 2 tests where the duration exceeded the maximum duration. -1. 0.300 (0.100) FooTest::test +1. 300 ms (100 ms) FooTest::test There is 1 additional slow test that is not listed here. TXT @@ -299,7 +299,7 @@ public static function provideExpectedReportMaximumDurationMaximumCountAndSlowTe <<<'TXT' Detected 3 tests where the duration exceeded the maximum duration. -1. 0.300 (0.100) FooTest::test +1. 300 ms (100 ms) FooTest::test There are 2 additional slow tests that are not listed here. TXT From 115f795a6be848e00a01cbb0cbb4b5278b248208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 14 Feb 2025 11:27:31 +0100 Subject: [PATCH 2/2] Report global maximum duration only once --- README.md | 24 ++++++------- src/Reporter/DefaultReporter.php | 35 ++++++++++++------- .../Configuration/Defaults/test.phpt | 24 ++++++------- .../Configuration/MaximumCount/test.phpt | 8 ++--- .../Configuration/MaximumDuration/test.phpt | 24 ++++++------- .../Version06/TestCase/Bare/test.phpt | 6 ++-- .../Version06/TestCase/Combination/test.phpt | 8 ++--- .../TestCase/WithAfterAnnotation/test.phpt | 8 ++--- .../WithAfterClassAnnotation/test.phpt | 6 ++-- .../WithAssertPostConditions/test.phpt | 8 ++--- .../WithAssertPreConditions/test.phpt | 8 ++--- .../TestCase/WithBeforeAnnotation/test.phpt | 8 ++--- .../WithBeforeClassAnnotation/test.phpt | 6 ++-- .../TestCase/WithDataProvider/test.phpt | 6 ++-- .../Version06/TestCase/WithSetUp/test.phpt | 8 ++--- .../TestCase/WithSetUpBeforeClass/test.phpt | 6 ++-- .../Version06/TestCase/WithTearDown/test.phpt | 8 ++--- .../TestCase/WithTearDownAfterClass/test.phpt | 6 ++-- .../test.phpt | 2 +- .../WithMaximumDurationAnnotation/test.phpt | 4 +-- .../test.phpt | 10 +++--- .../test.phpt | 2 +- .../WithSlowThresholdAnnotation/test.phpt | 4 +-- .../Configuration/Defaults/test.phpt | 24 ++++++------- .../Configuration/MaximumCount/test.phpt | 8 ++--- .../Configuration/MaximumDuration/test.phpt | 24 ++++++------- .../Version07/TestCase/Bare/test.phpt | 6 ++-- .../Version07/TestCase/Combination/test.phpt | 8 ++--- .../TestCase/WithAfterAnnotation/test.phpt | 8 ++--- .../WithAfterClassAnnotation/test.phpt | 6 ++-- .../WithAssertPostConditions/test.phpt | 8 ++--- .../WithAssertPreConditions/test.phpt | 8 ++--- .../TestCase/WithBeforeAnnotation/test.phpt | 8 ++--- .../WithBeforeClassAnnotation/test.phpt | 6 ++-- .../TestCase/WithDataProvider/test.phpt | 6 ++-- .../Version07/TestCase/WithSetUp/test.phpt | 8 ++--- .../TestCase/WithSetUpBeforeClass/test.phpt | 6 ++-- .../Version07/TestCase/WithTearDown/test.phpt | 8 ++--- .../TestCase/WithTearDownAfterClass/test.phpt | 6 ++-- .../test.phpt | 2 +- .../WithMaximumDurationAnnotation/test.phpt | 4 +-- .../test.phpt | 10 +++--- .../test.phpt | 2 +- .../WithSlowThresholdAnnotation/test.phpt | 4 +-- .../Configuration/Defaults/test.phpt | 24 ++++++------- .../Configuration/MaximumCount/test.phpt | 8 ++--- .../Configuration/MaximumDuration/test.phpt | 24 ++++++------- .../Version08/TestCase/Bare/test.phpt | 6 ++-- .../Version08/TestCase/Combination/test.phpt | 8 ++--- .../TestCase/WithAfterAnnotation/test.phpt | 8 ++--- .../WithAfterClassAnnotation/test.phpt | 6 ++-- .../WithAssertPostConditions/test.phpt | 8 ++--- .../WithAssertPreConditions/test.phpt | 8 ++--- .../TestCase/WithBeforeAnnotation/test.phpt | 8 ++--- .../WithBeforeClassAnnotation/test.phpt | 6 ++-- .../TestCase/WithDataProvider/test.phpt | 6 ++-- .../Version08/TestCase/WithSetUp/test.phpt | 8 ++--- .../TestCase/WithSetUpBeforeClass/test.phpt | 6 ++-- .../Version08/TestCase/WithTearDown/test.phpt | 8 ++--- .../TestCase/WithTearDownAfterClass/test.phpt | 6 ++-- .../test.phpt | 2 +- .../WithMaximumDurationAnnotation/test.phpt | 4 +-- .../test.phpt | 10 +++--- .../test.phpt | 2 +- .../WithSlowThresholdAnnotation/test.phpt | 4 +-- .../Configuration/Defaults/test.phpt | 24 ++++++------- .../Configuration/MaximumCount/test.phpt | 8 ++--- .../Configuration/MaximumDuration/test.phpt | 24 ++++++------- .../Version09/TestCase/Bare/test.phpt | 6 ++-- .../Version09/TestCase/Combination/test.phpt | 8 ++--- .../TestCase/WithAfterAnnotation/test.phpt | 8 ++--- .../WithAfterClassAnnotation/test.phpt | 6 ++-- .../WithAssertPostConditions/test.phpt | 8 ++--- .../WithAssertPreConditions/test.phpt | 8 ++--- .../TestCase/WithBeforeAnnotation/test.phpt | 8 ++--- .../WithBeforeClassAnnotation/test.phpt | 6 ++-- .../TestCase/WithDataProvider/test.phpt | 6 ++-- .../Version09/TestCase/WithSetUp/test.phpt | 8 ++--- .../TestCase/WithSetUpBeforeClass/test.phpt | 6 ++-- .../Version09/TestCase/WithTearDown/test.phpt | 8 ++--- .../TestCase/WithTearDownAfterClass/test.phpt | 6 ++-- .../test.phpt | 2 +- .../WithMaximumDurationAnnotation/test.phpt | 4 +-- .../test.phpt | 10 +++--- .../test.phpt | 2 +- .../WithSlowThresholdAnnotation/test.phpt | 4 +-- .../Configuration/Defaults/test.phpt | 24 ++++++------- .../Configuration/MaximumCount/test.phpt | 8 ++--- .../Configuration/MaximumDuration/test.phpt | 24 ++++++------- .../Version10/TestCase/Bare/test.phpt | 6 ++-- .../Version10/TestCase/Combination/test.phpt | 8 ++--- .../TestCase/WithAfterAnnotation/test.phpt | 8 ++--- .../TestCase/WithAfterAttribute/test.phpt | 8 ++--- .../WithAfterClassAnnotation/test.phpt | 6 ++-- .../WithAfterClassAttribute/test.phpt | 6 ++-- .../WithAssertPostConditions/test.phpt | 8 ++--- .../WithAssertPreConditions/test.phpt | 8 ++--- .../TestCase/WithBeforeAnnotation/test.phpt | 8 ++--- .../TestCase/WithBeforeAttribute/test.phpt | 8 ++--- .../WithBeforeClassAnnotation/test.phpt | 6 ++-- .../WithBeforeClassAttribute/test.phpt | 6 ++-- .../TestCase/WithDataProvider/test.phpt | 6 ++-- .../Version10/TestCase/WithSetUp/test.phpt | 8 ++--- .../TestCase/WithSetUpBeforeClass/test.phpt | 6 ++-- .../Version10/TestCase/WithTearDown/test.phpt | 8 ++--- .../TestCase/WithTearDownAfterClass/test.phpt | 6 ++-- .../test.phpt | 2 +- .../WithMaximumDurationAnnotation/test.phpt | 4 +-- .../WithMaximumDurationAttribute/test.phpt | 2 +- .../test.phpt | 10 +++--- .../test.phpt | 10 +++--- .../test.phpt | 2 +- .../WithSlowThresholdAnnotation/test.phpt | 4 +-- .../Configuration/Defaults/test.phpt | 24 ++++++------- .../Configuration/MaximumCount/test.phpt | 8 ++--- .../Configuration/MaximumDuration/test.phpt | 24 ++++++------- .../Version11/TestCase/Bare/test.phpt | 6 ++-- .../Version11/TestCase/Combination/test.phpt | 8 ++--- .../TestCase/WithAfterAttribute/test.phpt | 8 ++--- .../WithAfterClassAttribute/test.phpt | 6 ++-- .../WithAssertPostConditions/test.phpt | 8 ++--- .../WithAssertPreConditions/test.phpt | 8 ++--- .../TestCase/WithBeforeAttribute/test.phpt | 8 ++--- .../WithBeforeClassAttribute/test.phpt | 6 ++-- .../TestCase/WithDataProvider/test.phpt | 6 ++-- .../Version11/TestCase/WithSetUp/test.phpt | 8 ++--- .../TestCase/WithSetUpBeforeClass/test.phpt | 6 ++-- .../Version11/TestCase/WithTearDown/test.phpt | 8 ++--- .../TestCase/WithTearDownAfterClass/test.phpt | 6 ++-- .../test.phpt | 2 +- .../WithMaximumDurationAnnotation/test.phpt | 4 +-- .../WithMaximumDurationAttribute/test.phpt | 2 +- .../test.phpt | 10 +++--- .../test.phpt | 2 +- .../WithSlowThresholdAnnotation/test.phpt | 4 +-- .../Configuration/Defaults/test.phpt | 24 ++++++------- .../Configuration/MaximumCount/test.phpt | 8 ++--- .../Configuration/MaximumDuration/test.phpt | 24 ++++++------- .../Version12/TestCase/Bare/test.phpt | 6 ++-- .../Version12/TestCase/Combination/test.phpt | 8 ++--- .../TestCase/WithAfterAttribute/test.phpt | 8 ++--- .../WithAfterClassAttribute/test.phpt | 6 ++-- .../WithAssertPostConditions/test.phpt | 8 ++--- .../WithAssertPreConditions/test.phpt | 8 ++--- .../TestCase/WithBeforeAttribute/test.phpt | 8 ++--- .../WithBeforeClassAttribute/test.phpt | 6 ++-- .../TestCase/WithDataProvider/test.phpt | 6 ++-- .../Version12/TestCase/WithSetUp/test.phpt | 8 ++--- .../TestCase/WithSetUpBeforeClass/test.phpt | 6 ++-- .../Version12/TestCase/WithTearDown/test.phpt | 8 ++--- .../TestCase/WithTearDownAfterClass/test.phpt | 6 ++-- .../WithMaximumDurationAttribute/test.phpt | 2 +- .../test.phpt | 10 +++--- test/Unit/Reporter/DefaultReporterTest.php | 14 ++++---- 154 files changed, 653 insertions(+), 642 deletions(-) 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