From 68148e700c414fe99588880fedbd9336c772a3c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Mon, 25 Jan 2021 20:14:00 +0100 Subject: [PATCH] Enhancement: Compose maximum duration into SlowTest --- CHANGELOG.md | 2 + src/SlowTest.php | 19 ++- src/Subscriber/TestPassedSubscriber.php | 5 +- test/Unit/Collector/DefaultCollectorTest.php | 56 +++++-- test/Unit/Reporter/DefaultReporterTest.php | 155 ++++++++++-------- test/Unit/SlowTestTest.php | 9 +- .../Subscriber/TestPassedSubscriberTest.php | 5 +- .../TestSuiteFinishedSubscriberTest.php | 36 +++- 8 files changed, 191 insertions(+), 96 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b625849e..584b2eea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ For a full diff see [`7afa59c...main`][7afa59c...main]. * Renamed `Collector` to `Collector\DefaultCollector` and extracted `Collector\Collector` interface ([#24]), by [@localheinz] * Used `TimeKeeper` instead of `SlowTestCollector` in `Subscriber\TestPreparedSubscriber` ([#25]), by [@localheinz] * Used `TimeKeeper` and `Collector\Collector` instead of `SlowTestCollector` in `Subscriber\TestPassedSubscriber` ([#26]), by [@localheinz] +* Composed maximum duration into `SlowTest` ([#37]), by [@localheinz] ### Removed @@ -51,5 +52,6 @@ For a full diff see [`7afa59c...main`][7afa59c...main]. [#26]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/26 [#34]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/34 [#36]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/36 +[#37]: https://github.com/ergebnis/phpunit-slow-test-detector/pull/37 [@localheinz]: https://github.com/localheinz diff --git a/src/SlowTest.php b/src/SlowTest.php index 36570d0e..879d60b9 100644 --- a/src/SlowTest.php +++ b/src/SlowTest.php @@ -21,21 +21,27 @@ final class SlowTest private Event\Telemetry\Duration $duration; + private Event\Telemetry\Duration $maximumDuration; + private function __construct( Event\Code\Test $test, - Event\Telemetry\Duration $duration + Event\Telemetry\Duration $duration, + Event\Telemetry\Duration $maximumDuration ) { $this->test = $test; $this->duration = $duration; + $this->maximumDuration = $maximumDuration; } - public static function fromTestAndDuration( + public static function fromTestDurationAndMaximumDuration( Event\Code\Test $test, - Event\Telemetry\Duration $duration + Event\Telemetry\Duration $duration, + Event\Telemetry\Duration $maximumDuration ): self { return new self( $test, - $duration + $duration, + $maximumDuration ); } @@ -48,4 +54,9 @@ public function duration(): Event\Telemetry\Duration { return $this->duration; } + + public function maximumDuration(): Event\Telemetry\Duration + { + return $this->maximumDuration; + } } diff --git a/src/Subscriber/TestPassedSubscriber.php b/src/Subscriber/TestPassedSubscriber.php index d0b4a645..c91fe6f4 100644 --- a/src/Subscriber/TestPassedSubscriber.php +++ b/src/Subscriber/TestPassedSubscriber.php @@ -47,9 +47,10 @@ public function notify(Event\Test\Passed $event): void return; } - $slowTest = SlowTest::fromTestAndDuration( + $slowTest = SlowTest::fromTestDurationAndMaximumDuration( $event->test(), - $duration + $duration, + $this->maximumDuration ); $this->collector->collect($slowTest); diff --git a/test/Unit/Collector/DefaultCollectorTest.php b/test/Unit/Collector/DefaultCollectorTest.php index 40c81142..459532a9 100644 --- a/test/Unit/Collector/DefaultCollectorTest.php +++ b/test/Unit/Collector/DefaultCollectorTest.php @@ -42,36 +42,48 @@ public function testCollectCollectsSlowTests(): void { $faker = self::faker(); - $first = SlowTest::fromTestAndDuration( + $first = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'foo', 'foo with data set #123', ), + Event\Telemetry\Duration::fromSecondsAndNanoseconds( + $faker->numberBetween(), + $faker->numberBetween(0, 999_999_999) + ), Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(), $faker->numberBetween(0, 999_999_999) ) ); - $second = SlowTest::fromTestAndDuration( + $second = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'bar', 'bar', ), + Event\Telemetry\Duration::fromSecondsAndNanoseconds( + $faker->numberBetween(), + $faker->numberBetween(0, 999_999_999) + ), Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(), $faker->numberBetween(0, 999_999_999) ) ); - $third = SlowTest::fromTestAndDuration( + $third = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'baz', 'baz with data set "string"', ), + Event\Telemetry\Duration::fromSecondsAndNanoseconds( + $faker->numberBetween(), + $faker->numberBetween(0, 999_999_999) + ), Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(), $faker->numberBetween(0, 999_999_999) @@ -97,7 +109,7 @@ public function testCollectDoesNotReplaceSlowTestWhenDurationIsLessThanPreviousS { $faker = self::faker(); - $first = SlowTest::fromTestAndDuration( + $first = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'foo', @@ -106,22 +118,30 @@ public function testCollectDoesNotReplaceSlowTestWhenDurationIsLessThanPreviousS Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(1), $faker->numberBetween(0, 999_999_999) + ), + Event\Telemetry\Duration::fromSecondsAndNanoseconds( + $faker->numberBetween(), + $faker->numberBetween(0, 999_999_999) ) ); - $second = SlowTest::fromTestAndDuration( + $second = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'bar', 'bar', ), + Event\Telemetry\Duration::fromSecondsAndNanoseconds( + $faker->numberBetween(), + $faker->numberBetween(0, 999_999_999) + ), Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(), $faker->numberBetween(0, 999_999_999) ) ); - $thirdForSameTest = SlowTest::fromTestAndDuration( + $thirdForSameTest = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( $first->test()->className(), $first->test()->methodName(), @@ -130,6 +150,10 @@ public function testCollectDoesNotReplaceSlowTestWhenDurationIsLessThanPreviousS Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(0, $first->duration()->seconds() - 1), $faker->numberBetween(0, 999_999_999) + ), + Event\Telemetry\Duration::fromSecondsAndNanoseconds( + $faker->numberBetween(), + $faker->numberBetween(0, 999_999_999) ) ); @@ -151,7 +175,12 @@ public function testCollectReplacesSlowTestWhenDurationIsGreaterThanPreviousSlow { $faker = self::faker(); - $first = SlowTest::fromTestAndDuration( + $maximumDuration = Event\Telemetry\Duration::fromSecondsAndNanoseconds( + $faker->numberBetween(), + $faker->numberBetween(0, 999_999_999) + ); + + $first = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'foo', @@ -160,10 +189,11 @@ public function testCollectReplacesSlowTestWhenDurationIsGreaterThanPreviousSlow Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(), $faker->numberBetween(0, 999_999_999) - ) + ), + $maximumDuration ); - $second = SlowTest::fromTestAndDuration( + $second = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'bar', @@ -172,10 +202,11 @@ public function testCollectReplacesSlowTestWhenDurationIsGreaterThanPreviousSlow Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(), $faker->numberBetween(0, 999_999_999) - ) + ), + $maximumDuration ); - $thirdForSameTest = SlowTest::fromTestAndDuration( + $thirdForSameTest = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( $first->test()->className(), $first->test()->methodName(), @@ -184,7 +215,8 @@ public function testCollectReplacesSlowTestWhenDurationIsGreaterThanPreviousSlow Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween($first->duration()->seconds() + 1), $faker->numberBetween(0, 999_999_999) - ) + ), + $maximumDuration ); $collector = new DefaultCollector(); diff --git a/test/Unit/Reporter/DefaultReporterTest.php b/test/Unit/Reporter/DefaultReporterTest.php index 79bb5424..33a4be32 100644 --- a/test/Unit/Reporter/DefaultReporterTest.php +++ b/test/Unit/Reporter/DefaultReporterTest.php @@ -83,8 +83,13 @@ public function testReportReturnsEmptyStringWhenNoSlowTestsHaveBeenSpecified(): public function testReportReturnsReportWhenTheNumberOfSlowTestsIsSmallerThanTheMaximumCountAndLessThanOne(): void { + $maximumDuration = Event\Telemetry\Duration::fromSecondsAndNanoseconds( + 0, + 100_000_000 + ); + $slowTests = [ - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'foo', @@ -93,17 +98,13 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsSmallerThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 7, 890_123_456 - ) + ), + $maximumDuration ), ]; $durationFormatter = new ToMillisecondsDurationFormatter(); - $maximumDuration = Event\Telemetry\Duration::fromSecondsAndNanoseconds( - 0, - 100_000_000 - ); - $maximumNumber = \count($slowTests); $reporter = new DefaultReporter( @@ -127,8 +128,13 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsSmallerThanTheM { $faker = self::faker(); + $maximumDuration = Event\Telemetry\Duration::fromSecondsAndNanoseconds( + 0, + 100_000_000 + ); + $slowTests = [ - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'foo', @@ -137,9 +143,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsSmallerThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 7, 890_123_456 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'bar', @@ -148,9 +155,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsSmallerThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 12, 345_000_000 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'baz', @@ -159,9 +167,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsSmallerThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 0, 123_000_000 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'qux', @@ -170,9 +179,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsSmallerThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 3, 456_000_000 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'quz', @@ -181,17 +191,13 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsSmallerThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 1, 234_000_000 - ) + ), + $maximumDuration ), ]; $durationFormatter = new ToMillisecondsDurationFormatter(); - $maximumDuration = Event\Telemetry\Duration::fromSecondsAndNanoseconds( - 0, - 100_000_000 - ); - $maximumNumber = $faker->numberBetween(\count($slowTests) + 1); $reporter = new DefaultReporter( @@ -217,8 +223,13 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsSmallerThanTheM public function testReportReturnsReportWhenTheNumberOfSlowTestsIsEqualToTheMaximumCount(): void { + $maximumDuration = Event\Telemetry\Duration::fromSecondsAndNanoseconds( + 0, + 100_000_000 + ); + $slowTests = [ - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'foo', @@ -227,9 +238,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsEqualToTheMaxim Event\Telemetry\Duration::fromSecondsAndNanoseconds( 7, 890_123_456 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'bar', @@ -238,9 +250,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsEqualToTheMaxim Event\Telemetry\Duration::fromSecondsAndNanoseconds( 12, 345_000_000 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'baz', @@ -249,9 +262,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsEqualToTheMaxim Event\Telemetry\Duration::fromSecondsAndNanoseconds( 0, 123_000_000 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'qux', @@ -260,9 +274,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsEqualToTheMaxim Event\Telemetry\Duration::fromSecondsAndNanoseconds( 3, 456_000_000 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'quz', @@ -271,17 +286,13 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsEqualToTheMaxim Event\Telemetry\Duration::fromSecondsAndNanoseconds( 1, 234_000_000 - ) + ), + $maximumDuration ), ]; $durationFormatter = new ToMillisecondsDurationFormatter(); - $maximumDuration = Event\Telemetry\Duration::fromSecondsAndNanoseconds( - 0, - 100_000_000 - ); - $maximumNumber = \count($slowTests); $reporter = new DefaultReporter( @@ -307,8 +318,13 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsEqualToTheMaxim public function testReportReturnsReportWhenTheNumberOfSlowTestsIsOneMoreThanTheMaximumCount(): void { + $maximumDuration = Event\Telemetry\Duration::fromSecondsAndNanoseconds( + 0, + 100_000_000 + ); + $slowTests = [ - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'foo', @@ -317,9 +333,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsOneMoreThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 7, 890_123_456 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'bar', @@ -328,9 +345,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsOneMoreThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 12, 345_000_000 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'baz', @@ -339,9 +357,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsOneMoreThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 0, 123_000_000 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'qux', @@ -350,9 +369,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsOneMoreThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 3, 456_000_000 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'quz', @@ -361,17 +381,13 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsOneMoreThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 1, 234_000_000 - ) + ), + $maximumDuration ), ]; $durationFormatter = new ToMillisecondsDurationFormatter(); - $maximumDuration = Event\Telemetry\Duration::fromSecondsAndNanoseconds( - 0, - 100_000_000 - ); - $maximumNumber = \count($slowTests) - 1; $reporter = new DefaultReporter( @@ -398,8 +414,13 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsOneMoreThanTheM public function testReportReturnsReportWhenTheNumberOfSlowTestsIsGreaterThanTheMaximumCountPlusOne(): void { + $maximumDuration = Event\Telemetry\Duration::fromSecondsAndNanoseconds( + 0, + 100_000_000 + ); + $slowTests = [ - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'foo', @@ -408,9 +429,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsGreaterThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 7, 890_123_456 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'bar', @@ -419,9 +441,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsGreaterThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 12, 345_000_000 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'baz', @@ -430,9 +453,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsGreaterThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 0, 123_000_000 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'qux', @@ -441,9 +465,10 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsGreaterThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 3, 456_000_000 - ) + ), + $maximumDuration ), - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'quz', @@ -452,17 +477,13 @@ public function testReportReturnsReportWhenTheNumberOfSlowTestsIsGreaterThanTheM Event\Telemetry\Duration::fromSecondsAndNanoseconds( 1, 234_000_000 - ) + ), + $maximumDuration ), ]; $durationFormatter = new ToMillisecondsDurationFormatter(); - $maximumDuration = Event\Telemetry\Duration::fromSecondsAndNanoseconds( - 0, - 100_000_000 - ); - $maximumNumber = \count($slowTests) - 2; $reporter = new DefaultReporter( diff --git a/test/Unit/SlowTestTest.php b/test/Unit/SlowTestTest.php index ae8497ee..d73ca871 100644 --- a/test/Unit/SlowTestTest.php +++ b/test/Unit/SlowTestTest.php @@ -27,7 +27,7 @@ final class SlowTestTest extends Framework\TestCase { use Util\Helper; - public function testFromTestAndDurationReturnsSlowTest(): void + public function testFromTestDurationAndMaximumDurationReturnsSlowTest(): void { $faker = self::faker(); @@ -38,13 +38,16 @@ public function testFromTestAndDurationReturnsSlowTest(): void ); $duration = Event\Telemetry\Duration::fromSeconds($faker->numberBetween()); + $maximumDuration = Event\Telemetry\Duration::fromSeconds($faker->numberBetween()); - $slowTest = SlowTest::fromTestAndDuration( + $slowTest = SlowTest::fromTestDurationAndMaximumDuration( $test, - $duration + $duration, + $maximumDuration ); self::assertSame($test, $slowTest->test()); self::assertSame($duration, $slowTest->duration()); + self::assertSame($maximumDuration, $slowTest->maximumDuration()); } } diff --git a/test/Unit/Subscriber/TestPassedSubscriberTest.php b/test/Unit/Subscriber/TestPassedSubscriberTest.php index d4c06b97..858d0b45 100644 --- a/test/Unit/Subscriber/TestPassedSubscriberTest.php +++ b/test/Unit/Subscriber/TestPassedSubscriberTest.php @@ -230,9 +230,10 @@ public function testNotifyCollectsSlowTestWhenDurationIsGreaterThanMaximumDurati $subscriber->notify($passedTestEvent); $expected = [ - SlowTest::fromTestAndDuration( + SlowTest::fromTestDurationAndMaximumDuration( $passedTest, - $passedTime->duration($preparedTime) + $passedTime->duration($preparedTime), + $maximumDuration ), ]; diff --git a/test/Unit/Subscriber/TestSuiteFinishedSubscriberTest.php b/test/Unit/Subscriber/TestSuiteFinishedSubscriberTest.php index 309e0f59..cd0aff67 100644 --- a/test/Unit/Subscriber/TestSuiteFinishedSubscriberTest.php +++ b/test/Unit/Subscriber/TestSuiteFinishedSubscriberTest.php @@ -84,36 +84,48 @@ public function testNotifyDoesNothingWhenReporterHasNotReportedAnything(): void { $faker = self::faker(); - $first = SlowTest::fromTestAndDuration( + $first = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'foo', 'foo with data set #123', ), + Event\Telemetry\Duration::fromSecondsAndNanoseconds( + $faker->numberBetween(), + $faker->numberBetween(0, 999_999_999) + ), Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(), $faker->numberBetween(0, 999_999_999) ) ); - $second = SlowTest::fromTestAndDuration( + $second = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'bar', 'bar', ), + Event\Telemetry\Duration::fromSecondsAndNanoseconds( + $faker->numberBetween(), + $faker->numberBetween(0, 999_999_999) + ), Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(), $faker->numberBetween(0, 999_999_999) ) ); - $third = SlowTest::fromTestAndDuration( + $third = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'baz', 'baz with data set "string"', ), + Event\Telemetry\Duration::fromSecondsAndNanoseconds( + $faker->numberBetween(), + $faker->numberBetween(0, 999_999_999) + ), Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(), $faker->numberBetween(0, 999_999_999) @@ -174,36 +186,48 @@ public function testNotifyEchosReportWhenReporterHasReportedSomething(): void { $faker = self::faker(); - $first = SlowTest::fromTestAndDuration( + $first = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'foo', 'foo with data set #123', ), + Event\Telemetry\Duration::fromSecondsAndNanoseconds( + $faker->numberBetween(), + $faker->numberBetween(0, 999_999_999) + ), Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(), $faker->numberBetween(0, 999_999_999) ) ); - $second = SlowTest::fromTestAndDuration( + $second = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'bar', 'bar', ), + Event\Telemetry\Duration::fromSecondsAndNanoseconds( + $faker->numberBetween(), + $faker->numberBetween(0, 999_999_999) + ), Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(), $faker->numberBetween(0, 999_999_999) ) ); - $third = SlowTest::fromTestAndDuration( + $third = SlowTest::fromTestDurationAndMaximumDuration( new Event\Code\Test( Example\SleeperTest::class, 'baz', 'baz with data set "string"', ), + Event\Telemetry\Duration::fromSecondsAndNanoseconds( + $faker->numberBetween(), + $faker->numberBetween(0, 999_999_999) + ), Event\Telemetry\Duration::fromSecondsAndNanoseconds( $faker->numberBetween(), $faker->numberBetween(0, 999_999_999)