diff --git a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
index 2d35d00..0316b04 100644
--- a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
+++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
@@ -107,6 +107,8 @@ class ExtensionDiscovery {
    *   An associative array of Extension objects, keyed by extension name.
    */
   public function scan($type, $include_tests = NULL) {
+    $settings = Settings::getSingleton();
+
     // Determine the installation profile directories to scan for extensions,
     // unless explicit profile directories have been set.
     if (!isset($this->profileDirectories)) {
@@ -131,7 +133,7 @@ public function scan($type, $include_tests = NULL) {
     // Therefore, add the site directory of the parent site to the search paths,
     // so that contained extensions are still discovered.
     // @see \Drupal\simpletest\WebTestBase::setUp()
-    if ($parent_site = Settings::getSingleton()->get('test_parent_site')) {
+    if ($parent_site = $settings->get('test_parent_site')) {
       $searchdirs[static::ORIGIN_PARENT_SITE] = $parent_site;
     }
 
@@ -140,8 +142,10 @@ public function scan($type, $include_tests = NULL) {
 
     // Unless an explicit value has been passed, manually check whether we are
     // in a test environment, in which case test extensions must be included.
+    // Tests extensions can also be included for debugging purposes by setting a
+    // variable in settings.php.
     if (!isset($include_tests)) {
-      $include_tests = (bool) drupal_valid_test_ua();
+      $include_tests = drupal_valid_test_ua() || $settings->get('extension_discovery_scan_tests');
     }
 
     $files = array();
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index ad2c404..2a764b3 100644
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -512,6 +512,15 @@
 # $settings['rebuild_access'] = TRUE;
 
 /**
+ * Include test directories when discovering extensions.
+ *
+ * For performance, test directories are not scanned for extensions in regular
+ * runtime. In can be useful, however, to enable test extensions for development
+ * purposes.
+ */
+# $settings['extension_discovery_scan_tests'] = TRUE;
+
+/**
  * Base URL (optional).
  *
  * If Drupal is generating incorrect URLs on your site, which could
