void () { List<ThrowableRunnable<?>> actions = new ArrayList<>(); if (myProject != null) { Project project = myProject; actions.add(() -> { TestApplicationManager.tearDownProjectAndApp(myProject); myProject = null; }); for (ModuleFixtureBuilder<?> moduleFixtureBuilder : myModuleFixtureBuilders) { actions.add(() -> moduleFixtureBuilder.getFixture().tearDown()); } actions.add(() -> InjectedLanguageManagerImpl.checkInjectorsAreDisposed(project)); } JarFileSystemImpl.cleanupForNextTest(); for (Path fileToDelete : myFilesToDelete) { actions.add(() -> { List<IOException> errors; try (Stream<Path> stream = Files.walk(fileToDelete)) { errors = stream .sorted(Comparator.reverseOrder()) .map(x -> { try { Files.delete(x); return null; } catch (IOException e) { return e; } }) .filter(Objects::nonNull) .collect(Collectors.toList()); } catch (NoSuchFileException ignore) { errors = Collections.emptyList(); } CompoundRuntimeException.throwIfNotEmpty(errors); }); } actions.add(() -> { AccessToken projectTracker = this.projectTracker; if (projectTracker != null) { this.projectTracker = null; projectTracker.finish(); } }); actions.add(() -> super.tearDown()); actions.add(() -> { if (myEditorListenerTracker != null) { myEditorListenerTracker.checkListenersLeak(); } }); actions.add(() -> { if (myThreadTracker != null) { myThreadTracker.checkLeak(); } }); actions.add(() -> LightPlatformTestCase.checkEditorsReleased()); actions.add(() -> { if (myOldSdks != null) { myOldSdks.checkForJdkTableLeaks(); } }); // project is disposed by now, no point in passing it actions.add(() -> HeavyPlatformTestCase.cleanupApplicationCaches(null)); new RunAll(actions).run(); }