diff --git a/test/EndToEnd/Version10/CustomConfiguration/SleeperTest.php b/test/EndToEnd/Version10/CustomConfiguration/SleeperTest.php index 3a68eeb9..159ca41d 100644 --- a/test/EndToEnd/Version10/CustomConfiguration/SleeperTest.php +++ b/test/EndToEnd/Version10/CustomConfiguration/SleeperTest.php @@ -13,179 +13,15 @@ namespace Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\CustomConfiguration; -use Ergebnis\PHPUnit\SlowTestDetector\Attribute; use Ergebnis\PHPUnit\SlowTestDetector\Test; use PHPUnit\Framework; #[Framework\Attributes\CoversClass(Test\Fixture\Sleeper::class)] final class SleeperTest extends Framework\TestCase { - use Test\Util\Helper; - - public function testSleeperDoesNotSleepAtAll(): void - { - $milliseconds = 0; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * This DocBlock is intentionally left without a useful comment or annotation. - */ - public function testSleeperSleepsWithDocBlockWithoutSlowThresholdAnnotation(): void - { - $milliseconds = 90; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @maximumDuration 3.14 - */ - public function testSleeperSleepsWithDocBlockWithMaximumDurationAnnotationWhereValueIsNotAnInt(): void - { - $milliseconds = 110; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @maximumDuration 140 - */ - public function testSleeperSleepsShorterThanMaximumDurationFromMaximumDurationAnnotation(): void - { - $milliseconds = 130; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @maximumDuration 150 - */ - public function testSleeperSleepsLongerThanMaximumDurationFromMaximumDurationAnnotation(): void - { - $milliseconds = 150; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @maximumDuration 160 - * - * @slowThreshold 120 - */ - public function testSleeperSleepsLongerThanMaximumDurationFromMaximumDurationAnnotationWhenSlowThresholdAnnotationIsPresentAfterMaximumDuration(): void - { - $milliseconds = 170; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @slowThreshold 120 - * - * @maximumDuration 180 - */ - public function testSleeperSleepsLongerThanMaximumDurationFromMaximumDurationAnnotationWhenSlowThresholdAnnotationIsPresentBeforeMaximumDuration(): void - { - $milliseconds = 200; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 - * - * @slowThreshold 3.14 - */ - public function testSleeperSleepsWithDocBlockWithSlowThresholdAnnotationWhereValueIsNotAnInt(): void - { - $milliseconds = 40; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 - * - * @slowThreshold 100 - */ - public function testSleeperSleepsShorterThanMaximumDurationFromSlowThresholdAnnotation(): void - { - $milliseconds = 80; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 - * - * @slowThreshold 200 - */ - public function testSleeperSleepsLongerThanMaximumDurationFromSlowThresholdAnnotation(): void + #[Framework\Attributes\DataProvider('provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration')] + public function testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider(int $milliseconds): void { - $milliseconds = 220; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - #[Attribute\MaximumDuration(140)] - public function testSleeperSleepsShorterThanMaximumDurationFromMaximumDurationAttribute(): void - { - $milliseconds = 130; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - #[Attribute\MaximumDuration(160)] - public function testSleeperSleepsLongerThanMaximumDurationFromMaximumDurationAttribute(): void - { - $milliseconds = 160; - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); $sleeper->sleep(); @@ -194,17 +30,20 @@ public function testSleeperSleepsLongerThanMaximumDurationFromMaximumDurationAtt } /** - * @maximumDuration 20 + * @return \Generator */ - #[Attribute\MaximumDuration(50)] - public function testSleeperSleepsShorterThanMaximumDurationFromMaximumDurationAttributeWhenMaximumDurationAnnotationIsPresent(): void + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable { - $milliseconds = 40; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + $values = \range( + 300, + 500, + 50, + ); - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } } } diff --git a/test/EndToEnd/Version10/CustomConfiguration/phpunit.xml b/test/EndToEnd/Version10/CustomConfiguration/phpunit.xml index 3eee55e7..1c71e625 100644 --- a/test/EndToEnd/Version10/CustomConfiguration/phpunit.xml +++ b/test/EndToEnd/Version10/CustomConfiguration/phpunit.xml @@ -18,7 +18,7 @@ - + diff --git a/test/EndToEnd/Version10/CustomConfiguration/test.phpt b/test/EndToEnd/Version10/CustomConfiguration/test.phpt index 629b9e65..16030d69 100644 --- a/test/EndToEnd/Version10/CustomConfiguration/test.phpt +++ b/test/EndToEnd/Version10/CustomConfiguration/test.phpt @@ -1,5 +1,5 @@ --TEST-- -Configuring "maximum-count" parameter to 3 and "maximum-duration" parameter to 50 milliseconds +Configuring "maximum-count" parameter to 3 and "maximum-duration" parameter to 300 milliseconds --FILE-- sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + public function testSleeperSleepsLongerThanDefaultMaximumDuration(): void + { + $milliseconds = 750; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * This DocBlock is intentionally left without a useful comment or annotation. + */ + public function testSleeperSleepsShorterThanDefaultMaximumDurationWithUselessDocBlock(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * This DocBlock is intentionally left without a useful comment or annotation. + */ + public function testSleeperSleepsLongerThanDefaultMaximumDurationWithUselessDocBlock(): void + { + $milliseconds = 800; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 3.14 + */ + public function testSleeperSleepsShorterThanDefaultMaximumDurationWithInvalidMaximumDurationAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 3.14 + */ + public function testSleeperSleepsLongerThanDefaultMaximumDurationWithInvalidMaximumDurationAnnotation(): void + { + $milliseconds = 850; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 800 + */ + public function testSleeperSleepsShorterThanMaximumDurationFromAnnotationWithValidMaximumDurationAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 800 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidMaximumDurationAnnotation(): void + { + $milliseconds = 900; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + * + * @slowThreshold 3.14 + */ + public function testSleeperSleepsShorterThanDefaultMaximumDurationWithInvalidSlowThresholdAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + * + * @slowThreshold 3.14 + */ + public function testSleeperSleepsLongerThanDefaultMaximumDurationWithInvalidSlowThresholdAnnotation(): void + { + $milliseconds = 950; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + * + * @slowThreshold 950 + */ + public function testSleeperSleepsShorterThanSlowThresholdFromAnnotationWithValidSlowThresholdAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + * + * @slowThreshold 900 + */ + public function testSleeperSleepsLongerThanSlowThresholdFromAnnotationWithValidSlowThresholdAnnotation(): void + { + $milliseconds = 1000; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 1000 + * + * @slowThreshold 300 + */ + public function testSleeperSleepsShorterThanMaximumDurationFromAnnotationWithValidMaximumDurationAndSlowThresholdAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 1000 + * + * @slowThreshold 300 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidMaximumDurationAndSlowThresholdAnnotation(): void + { + $milliseconds = 1050; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @slowThreshold 300 + * + * @maximumDuration 1000 + */ + public function testSleeperSleepsShorterThanMaximumDurationFromAnnotationWithValidSlowThresholdAndMaximumDurationAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @slowThreshold 300 + * + * @maximumDuration 1000 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidSlowThresholdAndMaximumDurationAnnotation(): void + { + $milliseconds = 1100; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[Attribute\MaximumDuration(1100)] + public function testSleeperSleepsShorterThanMaximumDurationFromAttribute(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + #[Attribute\MaximumDuration(1100)] + public function testSleeperSleepsLongerThanMaximumDurationFromAttribute(): void + { + $milliseconds = 1150; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 25 + * + * @slowThreshold 30 + */ + #[Attribute\MaximumDuration(1150)] + public function testSleeperSleepsShorterThanMaximumDurationFromAttributeWithValidMaximumDurationAndSlowThresholdAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 25 + * + * @slowThreshold 30 + */ + #[Attribute\MaximumDuration(1150)] + public function testSleeperSleepsLongerThanMaximumDurationFromAttributeWithValidMaximumDurationAndSlowThresholdAnnotation(): void + { + $milliseconds = 1200; $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); @@ -45,11 +327,11 @@ public function testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvide /** * @return \Generator */ - public static function provideMillisecondsGreaterThanDefaultMaximumDuration(): \Generator + public static function provideMillisecondsGreaterThanDefaultMaximumDuration(): iterable { $values = \range( - 550, - 1050, + 500, + 500, 50, ); diff --git a/test/EndToEnd/Version10/DefaultConfiguration/test.phpt b/test/EndToEnd/Version10/DefaultConfiguration/test.phpt index aaa4f48e..a149dea6 100644 --- a/test/EndToEnd/Version10/DefaultConfiguration/test.phpt +++ b/test/EndToEnd/Version10/DefaultConfiguration/test.phpt @@ -21,23 +21,23 @@ Runtime: %s Configuration: %Stest/EndToEnd/Version10/DefaultConfiguration/phpunit.xml Random %seed: %s -............ 12 / 12 (100%) +..................... 21 / 21 (100%) Detected 11 tests that took longer than expected. - 1. 1.0%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#10 - 2. 1.0%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#9 - 3. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#8 - 4. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#7 - 5. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#6 - 6. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#5 - 7. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#4 - 8. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#3 - 9. 0.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#2 -10. 0.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider#1 + 1. 1.2%s (1.150) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromAttributeWithValidMaximumDurationAndSlowThresholdAnnotation + 2. 1.1%s (1.100) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromAttribute + 3. 1.1%s (1.000) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidSlowThresholdAndMaximumDurationAnnotation + 4. 1.0%s (1.000) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidMaximumDurationAndSlowThresholdAnnotation + 5. 1.0%s (0.900) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanSlowThresholdFromAnnotationWithValidSlowThresholdAnnotation + 6. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithInvalidSlowThresholdAnnotation + 7. 0.9%s (0.800) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidMaximumDurationAnnotation + 8. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithInvalidMaximumDurationAnnotation + 9. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithUselessDocBlock +10. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version10\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDuration There is 1 additional slow test that is not listed here. Time: %s, Memory: %s -OK (12 tests, 12 assertions) +OK (21 tests, 21 assertions) diff --git a/test/EndToEnd/Version8/CustomConfiguration/SleeperTest.php b/test/EndToEnd/Version8/CustomConfiguration/SleeperTest.php index de69f863..b4266243 100644 --- a/test/EndToEnd/Version8/CustomConfiguration/SleeperTest.php +++ b/test/EndToEnd/Version8/CustomConfiguration/SleeperTest.php @@ -21,40 +21,11 @@ */ final class SleeperTest extends Framework\TestCase { - use Test\Util\Helper; - - public function testSleeperDoesNotSleepAtAll(): void - { - $milliseconds = 0; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * This DocBlock is intentionally left without a useful comment or annotation. - */ - public function testSleeperSleepsWithDocBlockWithoutSlowThresholdAnnotation(): void - { - $milliseconds = 90; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - /** - * @maximumDuration 3.14 + * @dataProvider provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration */ - public function testSleeperSleepsWithDocBlockWithMaximumDurationAnnotationWhereValueIsNotAnInt(): void + public function testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider(int $milliseconds): void { - $milliseconds = 110; - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); $sleeper->sleep(); @@ -63,110 +34,20 @@ public function testSleeperSleepsWithDocBlockWithMaximumDurationAnnotationWhereV } /** - * @maximumDuration 140 + * @return \Generator */ - public function testSleeperSleepsShorterThanMaximumDurationFromMaximumDurationAnnotation(): void + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable { - $milliseconds = 130; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + $values = \range( + 300, + 500, + 50, + ); - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @maximumDuration 150 - */ - public function testSleeperSleepsLongerThanMaximumDurationFromMaximumDurationAnnotation(): void - { - $milliseconds = 150; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @maximumDuration 160 - * - * @slowThreshold 120 - */ - public function testSleeperSleepsLongerThanMaximumDurationFromMaximumDurationAnnotationWhenSlowThresholdAnnotationIsPresentAfterMaximumDuration(): void - { - $milliseconds = 170; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @slowThreshold 120 - * - * @maximumDuration 180 - */ - public function testSleeperSleepsLongerThanMaximumDurationFromMaximumDurationAnnotationWhenSlowThresholdAnnotationIsPresentBeforeMaximumDuration(): void - { - $milliseconds = 200; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 - * - * @slowThreshold 3.14 - */ - public function testSleeperSleepsWithDocBlockWithSlowThresholdAnnotationWhereValueIsNotAnInt(): void - { - $milliseconds = 40; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 - * - * @slowThreshold 100 - */ - public function testSleeperSleepsShorterThanMaximumDurationFromSlowThresholdAnnotation(): void - { - $milliseconds = 80; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 - * - * @slowThreshold 200 - */ - public function testSleeperSleepsLongerThanMaximumDurationFromSlowThresholdAnnotation(): void - { - $milliseconds = 220; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } } } diff --git a/test/EndToEnd/Version8/CustomConfiguration/phpunit.xml b/test/EndToEnd/Version8/CustomConfiguration/phpunit.xml index 638d2a3e..8523e331 100644 --- a/test/EndToEnd/Version8/CustomConfiguration/phpunit.xml +++ b/test/EndToEnd/Version8/CustomConfiguration/phpunit.xml @@ -25,7 +25,7 @@ 3 - 50 + 300 diff --git a/test/EndToEnd/Version8/CustomConfiguration/test.phpt b/test/EndToEnd/Version8/CustomConfiguration/test.phpt index 1508a5eb..46fab20a 100644 --- a/test/EndToEnd/Version8/CustomConfiguration/test.phpt +++ b/test/EndToEnd/Version8/CustomConfiguration/test.phpt @@ -1,5 +1,5 @@ --TEST-- -Configuring "maximum-count" parameter to 3 and "maximum-duration" parameter to 50 milliseconds +Configuring "maximum-count" parameter to 3 and "maximum-duration" parameter to 300 milliseconds --FILE-- sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + public function testSleeperSleepsLongerThanDefaultMaximumDuration(): void + { + $milliseconds = 750; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * This DocBlock is intentionally left without a useful comment or annotation. + */ + public function testSleeperSleepsShorterThanDefaultMaximumDurationWithUselessDocBlock(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * This DocBlock is intentionally left without a useful comment or annotation. + */ + public function testSleeperSleepsLongerThanDefaultMaximumDurationWithUselessDocBlock(): void + { + $milliseconds = 800; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 3.14 + */ + public function testSleeperSleepsShorterThanDefaultMaximumDurationWithInvalidMaximumDurationAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 3.14 + */ + public function testSleeperSleepsLongerThanDefaultMaximumDurationWithInvalidMaximumDurationAnnotation(): void + { + $milliseconds = 850; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 800 + */ + public function testSleeperSleepsShorterThanMaximumDurationFromAnnotationWithValidMaximumDurationAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 800 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidMaximumDurationAnnotation(): void + { + $milliseconds = 900; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + * + * @slowThreshold 3.14 + */ + public function testSleeperSleepsShorterThanDefaultMaximumDurationWithInvalidSlowThresholdAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + * + * @slowThreshold 3.14 + */ + public function testSleeperSleepsLongerThanDefaultMaximumDurationWithInvalidSlowThresholdAnnotation(): void + { + $milliseconds = 950; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + * + * @slowThreshold 950 + */ + public function testSleeperSleepsShorterThanSlowThresholdFromAnnotationWithValidSlowThresholdAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + * + * @slowThreshold 900 + */ + public function testSleeperSleepsLongerThanSlowThresholdFromAnnotationWithValidSlowThresholdAnnotation(): void + { + $milliseconds = 1000; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 1000 + * + * @slowThreshold 300 + */ + public function testSleeperSleepsShorterThanMaximumDurationFromAnnotationWithValidMaximumDurationAndSlowThresholdAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 1000 + * + * @slowThreshold 300 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidMaximumDurationAndSlowThresholdAnnotation(): void + { + $milliseconds = 1050; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @slowThreshold 300 + * + * @maximumDuration 1000 + */ + public function testSleeperSleepsShorterThanMaximumDurationFromAnnotationWithValidSlowThresholdAndMaximumDurationAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @slowThreshold 300 + * + * @maximumDuration 1000 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidSlowThresholdAndMaximumDurationAnnotation(): void + { + $milliseconds = 1100; $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); @@ -52,8 +275,8 @@ public function testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvide public static function provideMillisecondsGreaterThanDefaultMaximumDuration(): iterable { $values = \range( - 550, - 1050, + 500, + 600, 50, ); diff --git a/test/EndToEnd/Version8/DefaultConfiguration/test.phpt b/test/EndToEnd/Version8/DefaultConfiguration/test.phpt index d00a1298..334aee02 100644 --- a/test/EndToEnd/Version8/DefaultConfiguration/test.phpt +++ b/test/EndToEnd/Version8/DefaultConfiguration/test.phpt @@ -19,23 +19,23 @@ Runtime: %s Configuration: %Stest/EndToEnd/Version8/DefaultConfiguration/phpunit.xml Random %seed: %s -............ 12 / 12 (100%) +................... 19 / 19 (100%) Detected 11 tests that took longer than expected. - 1. 1.0%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #10 (1050) - 2. 1.0%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #9 (1000) - 3. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #8 (950) - 4. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #7 (900) - 5. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #6 (850) - 6. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #5 (800) - 7. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #4 (750) - 8. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #3 (700) - 9. 0.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #2 (650) -10. 0.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #1 (600) + 1. 1.1%s (1.000) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidSlowThresholdAndMaximumDurationAnnotation + 2. 1.0%s (1.000) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidMaximumDurationAndSlowThresholdAnnotation + 3. 1.0%s (0.900) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanSlowThresholdFromAnnotationWithValidSlowThresholdAnnotation + 4. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithInvalidSlowThresholdAnnotation + 5. 0.9%s (0.800) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidMaximumDurationAnnotation + 6. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithInvalidMaximumDurationAnnotation + 7. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithUselessDocBlock + 8. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDuration + 9. 0.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #2 (600) +10. 0.5%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version8\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #1 (550) There is 1 additional slow test that is not listed here. Time: %s, Memory: %s -OK (12 tests, 12 assertions) +OK (19 tests, 19 assertions) diff --git a/test/EndToEnd/Version9/CustomConfiguration/SleeperTest.php b/test/EndToEnd/Version9/CustomConfiguration/SleeperTest.php index abdf50c1..c71a2748 100644 --- a/test/EndToEnd/Version9/CustomConfiguration/SleeperTest.php +++ b/test/EndToEnd/Version9/CustomConfiguration/SleeperTest.php @@ -21,40 +21,11 @@ */ final class SleeperTest extends Framework\TestCase { - use Test\Util\Helper; - - public function testSleeperDoesNotSleepAtAll(): void - { - $milliseconds = 0; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * This DocBlock is intentionally left without a useful comment or annotation. - */ - public function testSleeperSleepsWithDocBlockWithoutSlowThresholdAnnotation(): void - { - $milliseconds = 90; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - /** - * @maximumDuration 3.14 + * @dataProvider provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration */ - public function testSleeperSleepsWithDocBlockWithMaximumDurationAnnotationWhereValueIsNotAnInt(): void + public function testSleeperSleepsLongerThanMaximumDurationFromXmlConfigurationWithDataProvider(int $milliseconds): void { - $milliseconds = 110; - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); $sleeper->sleep(); @@ -63,110 +34,20 @@ public function testSleeperSleepsWithDocBlockWithMaximumDurationAnnotationWhereV } /** - * @maximumDuration 140 + * @return \Generator */ - public function testSleeperSleepsShorterThanMaximumDurationFromMaximumDurationAnnotation(): void + public static function provideMillisecondsGreaterThanMaximumDurationFromXmlConfiguration(): iterable { - $milliseconds = 130; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + $values = \range( + 300, + 500, + 50, + ); - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @maximumDuration 150 - */ - public function testSleeperSleepsLongerThanMaximumDurationFromMaximumDurationAnnotation(): void - { - $milliseconds = 150; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @maximumDuration 160 - * - * @slowThreshold 120 - */ - public function testSleeperSleepsLongerThanMaximumDurationFromMaximumDurationAnnotationWhenSlowThresholdAnnotationIsPresentAfterMaximumDuration(): void - { - $milliseconds = 170; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @slowThreshold 120 - * - * @maximumDuration 180 - */ - public function testSleeperSleepsLongerThanMaximumDurationFromMaximumDurationAnnotationWhenSlowThresholdAnnotationIsPresentBeforeMaximumDuration(): void - { - $milliseconds = 200; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 - * - * @slowThreshold 3.14 - */ - public function testSleeperSleepsWithDocBlockWithSlowThresholdAnnotationWhereValueIsNotAnInt(): void - { - $milliseconds = 40; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 - * - * @slowThreshold 100 - */ - public function testSleeperSleepsShorterThanMaximumDurationFromSlowThresholdAnnotation(): void - { - $milliseconds = 80; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); - } - - /** - * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 - * - * @slowThreshold 200 - */ - public function testSleeperSleepsLongerThanMaximumDurationFromSlowThresholdAnnotation(): void - { - $milliseconds = 220; - - $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); - - $sleeper->sleep(); - - self::assertSame($milliseconds, $sleeper->milliseconds()); + foreach ($values as $value) { + yield $value => [ + $value, + ]; + } } } diff --git a/test/EndToEnd/Version9/CustomConfiguration/phpunit.xml b/test/EndToEnd/Version9/CustomConfiguration/phpunit.xml index adf2fc16..4331d2ee 100644 --- a/test/EndToEnd/Version9/CustomConfiguration/phpunit.xml +++ b/test/EndToEnd/Version9/CustomConfiguration/phpunit.xml @@ -25,7 +25,7 @@ 3 - 50 + 300 diff --git a/test/EndToEnd/Version9/CustomConfiguration/test.phpt b/test/EndToEnd/Version9/CustomConfiguration/test.phpt index 05f8cd24..7c53a499 100644 --- a/test/EndToEnd/Version9/CustomConfiguration/test.phpt +++ b/test/EndToEnd/Version9/CustomConfiguration/test.phpt @@ -1,5 +1,5 @@ --TEST-- -Configuring "maximum-count" parameter to 3 and "maximum-duration" parameter to 50 milliseconds +Configuring "maximum-count" parameter to 3 and "maximum-duration" parameter to 300 milliseconds --FILE-- sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + public function testSleeperSleepsLongerThanDefaultMaximumDuration(): void + { + $milliseconds = 750; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * This DocBlock is intentionally left without a useful comment or annotation. + */ + public function testSleeperSleepsShorterThanDefaultMaximumDurationWithUselessDocBlock(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * This DocBlock is intentionally left without a useful comment or annotation. + */ + public function testSleeperSleepsLongerThanDefaultMaximumDurationWithUselessDocBlock(): void + { + $milliseconds = 800; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 3.14 + */ + public function testSleeperSleepsShorterThanDefaultMaximumDurationWithInvalidMaximumDurationAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 3.14 + */ + public function testSleeperSleepsLongerThanDefaultMaximumDurationWithInvalidMaximumDurationAnnotation(): void + { + $milliseconds = 850; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 800 + */ + public function testSleeperSleepsShorterThanMaximumDurationFromAnnotationWithValidMaximumDurationAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 800 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidMaximumDurationAnnotation(): void + { + $milliseconds = 900; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + * + * @slowThreshold 3.14 + */ + public function testSleeperSleepsShorterThanDefaultMaximumDurationWithInvalidSlowThresholdAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + * + * @slowThreshold 3.14 + */ + public function testSleeperSleepsLongerThanDefaultMaximumDurationWithInvalidSlowThresholdAnnotation(): void + { + $milliseconds = 950; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + * + * @slowThreshold 950 + */ + public function testSleeperSleepsShorterThanSlowThresholdFromAnnotationWithValidSlowThresholdAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @see https://github.com/johnkary/phpunit-speedtrap/blob/1.0/src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php#L309-L331 + * + * @slowThreshold 900 + */ + public function testSleeperSleepsLongerThanSlowThresholdFromAnnotationWithValidSlowThresholdAnnotation(): void + { + $milliseconds = 1000; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 1000 + * + * @slowThreshold 300 + */ + public function testSleeperSleepsShorterThanMaximumDurationFromAnnotationWithValidMaximumDurationAndSlowThresholdAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @maximumDuration 1000 + * + * @slowThreshold 300 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidMaximumDurationAndSlowThresholdAnnotation(): void + { + $milliseconds = 1050; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @slowThreshold 300 + * + * @maximumDuration 1000 + */ + public function testSleeperSleepsShorterThanMaximumDurationFromAnnotationWithValidSlowThresholdAndMaximumDurationAnnotation(): void + { + $milliseconds = 50; + + $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); + + $sleeper->sleep(); + + self::assertSame($milliseconds, $sleeper->milliseconds()); + } + + /** + * @slowThreshold 300 + * + * @maximumDuration 1000 + */ + public function testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidSlowThresholdAndMaximumDurationAnnotation(): void + { + $milliseconds = 1100; $sleeper = Test\Fixture\Sleeper::fromMilliseconds($milliseconds); @@ -52,8 +275,8 @@ public function testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvide public static function provideMillisecondsGreaterThanDefaultMaximumDuration(): iterable { $values = \range( - 550, - 1050, + 500, + 600, 50, ); diff --git a/test/EndToEnd/Version9/DefaultConfiguration/test.phpt b/test/EndToEnd/Version9/DefaultConfiguration/test.phpt index 1ff712e6..1d9ed044 100644 --- a/test/EndToEnd/Version9/DefaultConfiguration/test.phpt +++ b/test/EndToEnd/Version9/DefaultConfiguration/test.phpt @@ -19,23 +19,23 @@ Runtime: %s Configuration: %Stest/EndToEnd/Version9/DefaultConfiguration/phpunit.xml Random %seed: %s -............ 12 / 12 (100%) +................... 19 / 19 (100%) Detected 11 tests that took longer than expected. - 1. 1.0%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #10 (1050) - 2. 1.0%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #9 (1000) - 3. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #8 (950) - 4. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #7 (900) - 5. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #6 (850) - 6. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #5 (800) - 7. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #4 (750) - 8. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #3 (700) - 9. 0.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #2 (650) -10. 0.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #1 (600) + 1. 1.1%s (1.000) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidSlowThresholdAndMaximumDurationAnnotation + 2. 1.0%s (1.000) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidMaximumDurationAndSlowThresholdAnnotation + 3. 1.0%s (0.900) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanSlowThresholdFromAnnotationWithValidSlowThresholdAnnotation + 4. 0.9%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithInvalidSlowThresholdAnnotation + 5. 0.9%s (0.800) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanMaximumDurationFromAnnotationWithValidMaximumDurationAnnotation + 6. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithInvalidMaximumDurationAnnotation + 7. 0.8%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithUselessDocBlock + 8. 0.7%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDuration + 9. 0.6%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #2 (600) +10. 0.5%s (0.500) Ergebnis\PHPUnit\SlowTestDetector\Test\EndToEnd\Version9\DefaultConfiguration\SleeperTest::testSleeperSleepsLongerThanDefaultMaximumDurationWithDataProvider with data set #1 (550) There is 1 additional slow test that is not listed here. Time: %s, Memory: %s -OK (12 tests, 12 assertions) +OK (19 tests, 19 assertions)