@Override
  public void runBare() throws Throwable {
    if (!shouldRunTest()) return;

    TestRunnerUtil.replaceIdeEventQueueSafely();
    try {
      runBareImpl();
    } finally {
      try {
        SwingUtilities.invokeAndWait(
            new Runnable() {
              @Override
              public void run() {
                cleanupApplicationCaches(getProject());
                resetAllFields();
              }
            });
      } catch (Throwable e) {
        // Ignore
      }
    }
  }
Exemple #2
0
  private static Test getTest(Class testCaseClass) {
    if ((testCaseClass.getModifiers() & Modifier.PUBLIC) == 0) return null;

    try {
      Method suiteMethod = testCaseClass.getMethod("suite", ArrayUtil.EMPTY_CLASS_ARRAY);
      return (Test) suiteMethod.invoke(null, ArrayUtil.EMPTY_CLASS_ARRAY);
    } catch (NoSuchMethodException e) {
      if (TestRunnerUtil.isJUnit4TestClass(testCaseClass)) {
        return new JUnit4TestAdapter(testCaseClass);
      }
      return new TestSuite(testCaseClass) {
        @Override
        public void addTest(Test test) {
          if (!(test instanceof TestCase)) {
            super.addTest(test);
          } else {
            Method method = findTestMethod((TestCase) test);
            if (method == null || !TestCaseLoader.isBombed(method)) {
              super.addTest(test);
            }
          }
        }

        private Method findTestMethod(final TestCase testCase) {
          try {
            return testCase.getClass().getMethod(testCase.getName());
          } catch (NoSuchMethodException e1) {
            return null;
          }
        }
      };
    } catch (Exception e) {
      System.err.println("Failed to execute suite ()");
      e.printStackTrace();
    }

    return null;
  }