@Override
 protected void tearDown() throws Exception {
   FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
   VirtualFile[] openFiles = editorManager.getOpenFiles();
   for (VirtualFile openFile : openFiles) {
     editorManager.closeFile(openFile);
   }
   deleteVFile();
   myEditor = null;
   myFile = null;
   myVFile = null;
   super.tearDown();
 }
  protected void setUpProject() throws Exception {
    myProjectManager = ProjectManagerEx.getInstanceEx();
    assertNotNull("Cannot instantiate ProjectManager component", myProjectManager);

    File projectFile = getIprFile();

    myProject = doCreateProject(projectFile);
    myProjectManager.openTestProject(myProject);
    LocalFileSystem.getInstance().refreshIoFiles(myFilesToDelete);

    setUpModule();

    setUpJdk();

    LightPlatformTestCase.clearUncommittedDocuments(getProject());

    runStartupActivities();
    ((FileTypeManagerImpl) FileTypeManager.getInstance()).drainReDetectQueue();
  }
  @Override
  protected void tearDown() throws Exception {
    List<Throwable> exceptions = new SmartList<Throwable>();
    Project project = myProject;
    if (project != null) {
      try {
        LightPlatformTestCase.doTearDown(project, ourApplication, false, exceptions);
      } catch (Throwable e) {
        exceptions.add(e);
      }

      disposeProject(exceptions);
    }

    try {
      checkForSettingsDamage(exceptions);
    } catch (Throwable e) {
      exceptions.add(e);
    }
    try {
      if (project != null) {
        try {
          InjectedLanguageManagerImpl.checkInjectorsAreDisposed(project);
        } catch (AssertionError e) {
          exceptions.add(e);
        }
      }
      try {
        for (final File fileToDelete : myFilesToDelete) {
          delete(fileToDelete);
        }
        LocalFileSystem.getInstance().refreshIoFiles(myFilesToDelete);
      } catch (Throwable e) {
        exceptions.add(e);
      }

      if (!myAssertionsInTestDetected) {
        if (IdeaLogger.ourErrorsOccurred != null) {
          exceptions.add(IdeaLogger.ourErrorsOccurred);
        }
      }

      try {
        super.tearDown();
      } catch (Throwable e) {
        exceptions.add(e);
      }

      try {
        if (myEditorListenerTracker != null) {
          myEditorListenerTracker.checkListenersLeak();
        }
      } catch (AssertionError error) {
        exceptions.add(error);
      }
      try {
        if (myThreadTracker != null) {
          myThreadTracker.checkLeak();
        }
      } catch (AssertionError error) {
        exceptions.add(error);
      }
      try {
        LightPlatformTestCase.checkEditorsReleased(exceptions);
      } catch (Throwable error) {
        exceptions.add(error);
      }
    } finally {
      myProjectManager = null;
      myProject = null;
      myModule = null;
      myFilesToDelete.clear();
      myEditorListenerTracker = null;
      myThreadTracker = null;
      ourTestCase = null;
    }
    CompoundRuntimeException.throwIfNotEmpty(exceptions);
  }