diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index 6e277638dc..1fa39357dd 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -33,10 +33,12 @@
 // In order to manage different method signatures between PHPUnit versions, we
 // dynamically load a compatibility trait dependent on the PHPUnit runner
 // version.
-if (class_exists('PHPUnit\Runner\Version') && version_compare(Version::id(), '7.0.0', '>=')) {
-  require_once __DIR__ . '/../Tests/PhpunitCompatibility7Trait.php';
-} else {
-  require_once __DIR__ . '/../Tests/PhpunitCompatibilityPre7Trait.php';
+if (!trait_exists('Drupal\Tests\PhpunitCompatibilityTrait', false)) {
+  if (class_exists('PHPUnit\Runner\Version') && version_compare(Version::id(), '7.0.0', '>=')) {
+    class_alias('Drupal\Tests\PhpunitCompatibility7Trait', 'Drupal\Tests\PhpunitCompatibilityTrait');
+  } else {
+    class_alias('Drupal\Tests\PhpunitCompatibilityPre7Trait', 'Drupal\Tests\PhpunitCompatibilityTrait');
+  }
 }
 
 /**
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index 8518fe3cd8..6e914d268d 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -27,10 +27,12 @@
 // In order to manage different method signatures between PHPUnit versions, we
 // dynamically load a compatibility trait dependent on the PHPUnit runner
 // version.
-if (class_exists('PHPUnit\Runner\Version') && version_compare(Version::id(), '7.0.0', '>=')) {
-  require_once __DIR__ . '/PhpunitCompatibility7Trait.php';
-} else {
-  require_once __DIR__ . '/PhpunitCompatibilityPre7Trait.php';
+if (!trait_exists('Drupal\Tests\PhpunitCompatibilityTrait', false)) {
+  if (class_exists('PHPUnit\Runner\Version') && version_compare(Version::id(), '7.0.0', '>=')) {
+    class_alias('Drupal\Tests\PhpunitCompatibility7Trait', 'Drupal\Tests\PhpunitCompatibilityTrait');
+  } else {
+    class_alias('Drupal\Tests\PhpunitCompatibilityPre7Trait', 'Drupal\Tests\PhpunitCompatibilityTrait');
+  }
 }
 
 /**
diff --git a/core/tests/Drupal/Tests/PhpunitCompatibility7Trait.php b/core/tests/Drupal/Tests/PhpunitCompatibility7Trait.php
index 0af1ef0c44..f31ed09e0f 100644
--- a/core/tests/Drupal/Tests/PhpunitCompatibility7Trait.php
+++ b/core/tests/Drupal/Tests/PhpunitCompatibility7Trait.php
@@ -8,7 +8,7 @@
 /**
  * Makes Drupal's test API forward compatible with multiple versions of PHPUnit.
  */
-trait PhpunitCompatibilityTrait {
+trait PhpunitCompatibility7Trait {
 
   /**
    * Returns a mock object for the specified class using the available method.
diff --git a/core/tests/Drupal/Tests/PhpunitCompatibilityPre7Trait.php b/core/tests/Drupal/Tests/PhpunitCompatibilityPre7Trait.php
index 79602adb3a..3f2a490717 100644
--- a/core/tests/Drupal/Tests/PhpunitCompatibilityPre7Trait.php
+++ b/core/tests/Drupal/Tests/PhpunitCompatibilityPre7Trait.php
@@ -7,7 +7,7 @@
 /**
  * Makes Drupal's test API forward compatible with multiple versions of PHPUnit.
  */
-trait PhpunitCompatibilityTrait {
+trait PhpunitCompatibilityPre7Trait {
 
   /**
    * Returns a mock object for the specified class using the available method.
diff --git a/core/tests/Drupal/Tests/PhpunitCompatibilityTraitTest.php b/core/tests/Drupal/Tests/PhpunitCompatibilityTraitTest.php
index a4271fe551..39b10c33c6 100644
--- a/core/tests/Drupal/Tests/PhpunitCompatibilityTraitTest.php
+++ b/core/tests/Drupal/Tests/PhpunitCompatibilityTraitTest.php
@@ -2,7 +2,18 @@
 
 namespace Drupal\Tests;
 
-require_once __DIR__ . '/PhpunitCompatibilityPre7Trait.php';
+use PHPUnit\Runner\Version;
+
+// In order to manage different method signatures between PHPUnit versions, we
+// dynamically load a compatibility trait dependent on the PHPUnit runner
+// version.
+if (!trait_exists('Drupal\Tests\PhpunitCompatibilityTrait', false)) {
+  if (class_exists('PHPUnit\Runner\Version') && version_compare(Version::id(), '7.0.0', '>=')) {
+    class_alias('Drupal\Tests\PhpunitCompatibility7Trait', 'Drupal\Tests\PhpunitCompatibilityTrait');
+  } else {
+    class_alias('Drupal\Tests\PhpunitCompatibilityPre7Trait', 'Drupal\Tests\PhpunitCompatibilityTrait');
+  }
+}
 
 /**
  * Tests the PHPUnit forward compatibility trait.
@@ -14,6 +25,7 @@ class PhpunitCompatibilityTraitTest extends UnitTestCase {
   /**
    * Tests that getMock is available and calls the correct parent method.
    *
+   * @covers \Drupal\Tests\PhpunitForwardCompatibilityTrait::getMock
    * @dataProvider providerMockVersions
    */
   public function testGetMock($className, $expected) {
@@ -24,6 +36,7 @@ public function testGetMock($className, $expected) {
   /**
    * Tests that createMock is available and calls the correct parent method.
    *
+   * @covers \Drupal\Tests\PhpunitCompatibilityTrait::createMock
    * @dataProvider providerMockVersions
    */
   public function testCreateMock($className, $expected) {
diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php
index e4974ff3f0..869fe67e4d 100644
--- a/core/tests/Drupal/Tests/UnitTestCase.php
+++ b/core/tests/Drupal/Tests/UnitTestCase.php
@@ -15,10 +15,12 @@
 // In order to manage different method signatures between PHPUnit versions, we
 // dynamically load a compatibility trait dependent on the PHPUnit runner
 // version.
-if (class_exists('PHPUnit\Runner\Version') && version_compare(Version::id(), '7.0.0', '>=')) {
-  require_once __DIR__ . '/PhpunitCompatibility7Trait.php';
-} else {
-  require_once __DIR__ . '/PhpunitCompatibilityPre7Trait.php';
+if (!trait_exists('Drupal\Tests\PhpunitCompatibilityTrait', false)) {
+  if (class_exists('PHPUnit\Runner\Version') && version_compare(Version::id(), '7.0.0', '>=')) {
+    class_alias('Drupal\Tests\PhpunitCompatibility7Trait', 'Drupal\Tests\PhpunitCompatibilityTrait');
+  } else {
+    class_alias('Drupal\Tests\PhpunitCompatibilityPre7Trait', 'Drupal\Tests\PhpunitCompatibilityTrait');
+  }
 }
 
 /**
