diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index e534003..8c90b76 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -1231,7 +1231,21 @@ function install_select_profile(&$install_state) {
       throw new NoProfilesException(\Drupal::service('string_translation'));
     }
     // Try to automatically select a profile.
-    if ($profile = _install_select_profile($install_state)) {
+    $profiles = $install_state['profiles'];
+    foreach ($profiles as $key => $profile) {
+      $details = install_profile_info($profile->name);
+      // Remove hidden profiles (such as the testing profile, which only exists
+      // to speed up test runs) from the list. This prevents them from being
+      // displayed in the user interface, and also means that if there is only
+      // one non-hidden profile, _install_select_profile() will choose it
+      // automatically.
+      if (!empty($details['hidden'])) {
+        unset($profiles[$key]);
+      }
+    }
+    $profile = _install_select_profile($profiles);
+    $install_state['profiles'] = $profiles;
+    if ($profile) {
       $install_state['parameters']['profile'] = $profile;
     }
     else {
@@ -1305,11 +1319,6 @@ function install_select_profile_form($form, &$form_state, $install_state) {
     if (!isset($details['type']) || $details['type'] != 'profile') {
       continue;
     }
-    // Don't show hidden profiles. This is used by to hide the testing profile,
-    // which only exists to speed up test runs.
-    if ($details['hidden'] === TRUE) {
-      continue;
-    }
     $profiles[$profile->getName()] = $details;
 
     // Determine the name of the profile; default to file name if defined name
