diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module
index 52243c8..2bc81d6 100644
--- a/core/modules/simpletest/simpletest.module
+++ b/core/modules/simpletest/simpletest.module
@@ -287,15 +287,19 @@ function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpun
  *   The command that can be run through exec().
  */
 function simpletest_phpunit_command() {
+  $autoloader = require \Drupal::root() . '/autoload.php';
+  $reflector = new ReflectionClass($autoloader);
+  $composer_root = dirname(dirname($reflector->getFileName()));
+
   // Don't use the committed version in composer's bin dir if running on
   // windows.
   if (substr(PHP_OS, 0, 3) == 'WIN') {
     $php_executable_finder = new PhpExecutableFinder();
     $php = $php_executable_finder->find();
-    $phpunit_bin = escapeshellarg($php) . " -f " . escapeshellarg(\Drupal::root() . "/core/vendor/phpunit/phpunit/composer/bin/phpunit") . " --";
+    $phpunit_bin = escapeshellarg($php) . " -f " . escapeshellarg($composer_root . '/phpunit/phpunit/composer/bin/phpunit') . " --";
   }
   else {
-    $phpunit_bin = \Drupal::root() . "/core/vendor/bin/phpunit";
+    $phpunit_bin = $composer_root . "/phpunit/phpunit/phpunit";
   }
   return $phpunit_bin;
 }
