diff --git a/core/modules/migrate/tests/src/Kernel/MigrateSourceTestBase.php b/core/modules/migrate/tests/src/Kernel/MigrateSourceTestBase.php
index 6cc02b6f81a012852ac13ea6a4c93b74ad459f05..f102b4b411266564e2939d424c08a728ce51f7bb 100644
--- a/core/modules/migrate/tests/src/Kernel/MigrateSourceTestBase.php
+++ b/core/modules/migrate/tests/src/Kernel/MigrateSourceTestBase.php
@@ -6,7 +6,6 @@
 use Drupal\migrate\Plugin\MigrateIdMapInterface;
 use Drupal\migrate\Plugin\MigrationInterface;
 use Drupal\migrate\Row;
-use PHPUnit\Util\Test;
 
 /**
  * Base class for tests of Migrate source plugins.
@@ -78,13 +77,9 @@ protected function setUp(): void {
    * @return string
    */
   protected function getPluginClass() {
-    $annotations = Test::parseTestMethodAnnotations(
-      static::class,
-      $this->name()
-    );
-
-    if (isset($annotations['class']['covers'])) {
-      return $annotations['class']['covers'][0];
+    $covers = $this->getTestClassCovers();
+    if (!empty($covers)) {
+      return $covers[0];
     }
     else {
       $this->fail('No plugin class was specified');
diff --git a/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php
index 8d647a5c74856ff63e87c47ec76eef0eb43b0561..06d874e2859bbfa44ad978a1af2a635b2ff5eeb0 100644
--- a/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php
+++ b/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit9/TestCompatibilityTrait.php
@@ -4,6 +4,8 @@
 
 namespace Drupal\TestTools\PhpUnitCompatibility\PhpUnit9;
 
+use PHPUnit\Util\Test;
+
 /**
  * Drupal's forward compatibility layer with multiple versions of PHPUnit.
  */
@@ -16,4 +18,15 @@ public function name(): string {
     return $this->getName();
   }
 
+  /**
+   * Gets @covers defined on the test class.
+   *
+   * @return string[]
+   *   An array of classes listed with the @covers annotation.
+   */
+  public function getTestClassCovers(): array {
+    $annotations = Test::parseTestMethodAnnotations(static::class, $this->name());
+    return $annotations['class']['covers'] ?? [];
+  }
+
 }