diff --git a/typo3/sysext/core/Classes/Core/Bootstrap.php b/typo3/sysext/core/Classes/Core/Bootstrap.php
index 7ccaf988a7e8fc6541bfa84f3ce3065227c900b5..3bbaacb117e51eba7ec1030ecf3a47aa9631c879 100644
--- a/typo3/sysext/core/Classes/Core/Bootstrap.php
+++ b/typo3/sysext/core/Classes/Core/Bootstrap.php
@@ -182,7 +182,7 @@ class Bootstrap {
 	 */
 	public function baseSetup($relativePathPart = '') {
 		SystemEnvironmentBuilder::run($relativePathPart);
-		if (!self::$usesComposerClassLoading) {
+		if (!self::$usesComposerClassLoading && ClassLoadingInformation::isClassLoadingInformationAvailable()) {
 			ClassLoadingInformation::registerClassLoadingInformation();
 		}
 		GeneralUtility::presetApplicationContext($this->applicationContext);
@@ -414,7 +414,7 @@ class Bootstrap {
 	 * @internal This is not a public API method, do not use in own extensions
 	 */
 	public function ensureClassLoadingInformationExists() {
-		if (!self::$usesComposerClassLoading && !ClassLoadingInformation::classLoadingInformationExists()) {
+		if (!self::$usesComposerClassLoading && !ClassLoadingInformation::isClassLoadingInformationAvailable()) {
 			ClassLoadingInformation::dumpClassLoadingInformation();
 			ClassLoadingInformation::registerClassLoadingInformation();
 		}
diff --git a/typo3/sysext/core/Classes/Core/ClassLoadingInformation.php b/typo3/sysext/core/Classes/Core/ClassLoadingInformation.php
index 768dd9deed8c9dfc185381d63917d5e0a63e6f0b..8ff5c38de7b9a17cdc5f464c9e3955ec6db87390 100644
--- a/typo3/sysext/core/Classes/Core/ClassLoadingInformation.php
+++ b/typo3/sysext/core/Classes/Core/ClassLoadingInformation.php
@@ -56,13 +56,13 @@ class ClassLoadingInformation {
 	const AUTOLOAD_CLASSALIASMAP_FILENAME = 'autoload_classaliasmap.php';
 
 	/**
-	 * Checks if the autoload_classmap.php exists. Used to see if the ClassLoadingInformationGenerator
-	 * should be called.
+	 * Checks if the autoload_classmap.php exists and we are not in testing context.
+	 * Used to see if the ClassLoadingInformationGenerator should be called.
 	 *
 	 * @return bool
 	 */
-	static public function classLoadingInformationExists() {
-		return file_exists(self::getClassLoadingInformationDirectory() . self::AUTOLOAD_CLASSMAP_FILENAME);
+	static public function isClassLoadingInformationAvailable() {
+		return !self::isTestingContext() && file_exists(self::getClassLoadingInformationDirectory() . self::AUTOLOAD_CLASSMAP_FILENAME);
 	}
 
 	/**
@@ -170,8 +170,6 @@ class ClassLoadingInformation {
 		$autoloadInfoDir = self::getClassLoadingInformationDirectory();
 		if (!file_exists($autoloadInfoDir)) {
 			GeneralUtility::mkdir_deep($autoloadInfoDir);
-		} elseif (self::isTestingContext()) {
-			GeneralUtility::flushDirectory($autoloadInfoDir, TRUE);
 		}
 	}