diff --git a/src/Util/Test.php b/src/Util/Test.php index c0c1ec78f63..fe23e05b739 100644 --- a/src/Util/Test.php +++ b/src/Util/Test.php @@ -10,6 +10,7 @@ namespace PHPUnit\Util; use PharIo\Version\VersionConstraintParser; +use PHPUnit\Framework\Assert; use PHPUnit\Framework\CodeCoverageException; use PHPUnit\Framework\Exception; use PHPUnit\Framework\InvalidCoversTargetException; @@ -706,6 +707,14 @@ public static function getHookMethods(string $className): array $class = new ReflectionClass($className); foreach ($class->getMethods() as $method) { + if ($method->getDeclaringClass()->getName() === Assert::class) { + continue; + } + + if ($method->getDeclaringClass()->getName() === TestCase::class) { + continue; + } + if (self::isBeforeClassMethod($method)) { \array_unshift( self::$hookMethods[$className]['beforeClass'],