diff --git a/core/lib/Drupal/Core/Test/TestRunnerKernel.php b/core/lib/Drupal/Core/Test/TestRunnerKernel.php
index fa9fd51..1e26e2c 100644
--- a/core/lib/Drupal/Core/Test/TestRunnerKernel.php
+++ b/core/lib/Drupal/Core/Test/TestRunnerKernel.php
@@ -51,8 +51,18 @@ public function __construct($environment, $class_loader) {
    * {@inheritdoc}
    */
   public function boot() {
-    // Ensure that required Settings exist.
-    if (!Settings::getAll()) {
+    if ($settings = Settings::getAll()) {
+      // See hook_simpletest_alter() why this is necessary.
+      if (isset($settings['testing_module_data'])) {
+        foreach ($settings['testing_module_data'] as $module_name => $module_data) {
+          $module_data += ['type' => 'module', 'filename' => "$module_name.module", 'weight' => 0];
+          $this->moduleData[$module_name] = new Extension(DRUPAL_ROOT, $module_data['type'], $module_data['pathname'], $module_data['filename']);
+          $this->moduleList[$module_name] = $module_data['weight'];
+        }
+      }
+    }
+    else {
+      // Ensure that required Settings exist.
       new Settings(array(
         'hash_salt' => 'run-tests',
         'container_yamls' => [],
diff --git a/core/modules/simpletest/simpletest.api.php b/core/modules/simpletest/simpletest.api.php
index e5251b7..17df5bb 100644
--- a/core/modules/simpletest/simpletest.api.php
+++ b/core/modules/simpletest/simpletest.api.php
@@ -13,6 +13,26 @@
 /**
  * Alter the list of tests.
  *
+ * This will not work with the run-tests.sh command line test runner script
+ * because the test runner presumes to run without Drupal installed so the
+ * modules containing the implementations are not loaded. So if this hook is
+ * implemented in a module then the test runner needs to be told which modules
+ * to load. This can be done via a settings called 'testing_module_data' in
+ * settings.php containing a list modules:
+ * @code
+ * $settings['testing_module_data'] = [
+ *   'foo' => [
+ *     'pathname' => 'modules/foo/foo.info.yml',
+ *     'type' => 'module',
+ *     'filename' => 'foo.module',
+ *     'weight' => 0,
+ *   ],
+ * ];
+ * @encode
+ *
+ * Only the pathname is mandatory for each module, 'type' defaults to module,
+ * 'weight' to 0, filename to 'modulename.module'.
+ *
  * @param $groups
  *   A two dimensional array, the first key is the test group, the second is the
  *   name of the test class, and the value is in associative array containing
