Beispiel #1
0
 /**
  * Convinient conversion of testSomeTest -> someTest | SomeTest where testSomeTest is the name of
  * current test.
  *
  * @param lowercaseFirstLetter - whether first letter after test should be lowercased.
  */
 protected String getTestName(boolean lowercaseFirstLetter) {
   String name = getName();
   assertTrue("Test name should start with 'test'", name.startsWith("test"));
   name = name.substring("test".length());
   if (lowercaseFirstLetter && !UsefulTestCase.isAllUppercaseName(name)) {
     name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
   }
   return name;
 }
Beispiel #2
0
  private void resetClassFields(final Class<?> aClass) {
    try {
      UsefulTestCase.clearDeclaredFields(this, aClass);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }

    if (aClass == LightPlatformTestCase.class) return;
    resetClassFields(aClass.getSuperclass());
  }
Beispiel #3
0
  public static void doTearDown() throws Exception {
    UsefulTestCase.doPostponedFormatting(ourProject);

    LookupManager.getInstance(ourProject).hideActiveLookup();

    InspectionProfileManager.getInstance().deleteProfile(PROFILE);
    assertNotNull("Application components damaged", ProjectManager.getInstance());

    ApplicationManager.getApplication()
        .runWriteAction(
            new Runnable() {
              public void run() {
                try {
                  final VirtualFile[] children = ourSourceRoot.getChildren();
                  for (VirtualFile child : children) {
                    child.delete(this);
                  }
                } catch (IOException e) {
                  //noinspection CallToPrintStackTrace
                  e.printStackTrace();
                }
                FileDocumentManager manager = FileDocumentManager.getInstance();
                if (manager instanceof FileDocumentManagerImpl) {
                  ((FileDocumentManagerImpl) manager).dropAllUnsavedDocuments();
                }
              }
            });
    //    final Project[] openProjects = ProjectManagerEx.getInstanceEx().getOpenProjects();
    //    assertTrue(Arrays.asList(openProjects).contains(ourProject));
    assertFalse(PsiManager.getInstance(getProject()).isDisposed());
    if (!ourAssertionsInTestDetected) {
      if (IdeaLogger.ourErrorsOccurred != null) {
        throw IdeaLogger.ourErrorsOccurred;
      }
      // assertTrue("Logger errors occurred. ", IdeaLogger.ourErrorsOccurred == null);
    }
    ((PsiDocumentManagerImpl) PsiDocumentManager.getInstance(getProject()))
        .clearUncommitedDocuments();

    ((UndoManagerImpl) UndoManager.getGlobalInstance()).dropHistoryInTests();

    ProjectManagerEx.getInstanceEx().setCurrentTestProject(null);
    ourApplication.setDataProvider(null);
    ourTestCase = null;
    ((PsiManagerImpl) ourPsiManager).cleanupForNextTest();

    final Editor[] allEditors = EditorFactory.getInstance().getAllEditors();
    if (allEditors.length > 0) {
      for (Editor allEditor : allEditors) {
        EditorFactory.getInstance().releaseEditor(allEditor);
      }
      fail("Unreleased editors: " + allEditors.length);
    }
  }
Beispiel #4
0
  protected void setUp() throws Exception {
    super.setUp();
    initApplication(this);
    doSetup(
        new SimpleLightProjectDescriptor(getModuleType(), getProjectJDK()),
        configureLocalInspectionTools(),
        myAvailableInspectionTools);
    storeSettings();

    myThreadTracker = new ThreadTracker();
  }
Beispiel #5
0
  protected void tearDown() throws Exception {
    ((StartupManagerImpl) StartupManager.getInstance(getProject())).prepareForNextTest();
    checkAllTimersAreDisposed();

    CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
    checkForSettingsDamage();
    doTearDown();

    super.tearDown();

    myThreadTracker.checkLeak();
  }