private void addFailures(
     List<ITestElement> failures, ITestElement testElement, ITestElementPredicate predicate) {
   Result testResult = testElement.getTestResult(true);
   if ((testResult == Result.ERROR || testResult == Result.FAILURE)
       && predicate.matches(testElement)) {
     failures.add(testElement);
   }
   if (testElement instanceof TestSuiteElement) {
     TestSuiteElement testSuiteElement = (TestSuiteElement) testElement;
     ITestElement[] children = testSuiteElement.getChildren();
     for (int i = 0; i < children.length; i++) {
       addFailures(failures, children[i], predicate);
     }
   }
 }
  /**
   * @param testElement
   * @param launchMode
   * @return <code>false</code> iff the rerun could not be started
   * @throws CoreException
   */
  public boolean rerunTest(ITestElement testElement, String launchMode) throws CoreException {
    if (isKeptAlive()) {
      Status status = ((TestCaseElement) getTestElement(testElement.getId())).getStatus();
      if (status == Status.ERROR) {
        fErrorCount--;
      } else if (status == Status.FAILURE) {
        fFailureCount--;
      }
      /* TODO fTestRunnerClient.rerunTest(testId, className, testName); */
      return true;

    } else if (fLaunch != null) {
      if (testRunnerUI instanceof ITestRunnerUIExtension) {
        return ((ITestRunnerUIExtension) testRunnerUI).rerunTest(fLaunch, testElement, launchMode);
      }
      // run the selected test using the previous launch configuration
      ILaunchConfiguration launchConfiguration = fLaunch.getLaunchConfiguration();
      if (launchConfiguration != null) {

        // String name= className;
        // if (testName != null)
        // name+= "."+testName; //$NON-NLS-1$
        // String configName= Messages.format(DLTKTestingMessages.TestRunnerViewPart_configName,
        // name);
        // ILaunchConfigurationWorkingCopy tmp= launchConfiguration.copy(configName);
        // fix for bug: 64838  junit view run single test does not use correct class [JUnit]
        //				tmp.setAttribute(ScriptLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, className);
        // reset the container
        // tmp.setAttribute(DLTKTestingConstants.ATTR_TEST_CONTAINER, ""); //$NON-NLS-1$
        // if (testName != null) {
        // tmp.setAttribute(DLTKTestingConstants.ATTR_TEST_METHOD_NAME, testName);
        //	String args= "-rerun "+testId;
        //	tmp.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args);
        // }
        // tmp.launch(launchMode, null);
        return true;
      }
    }

    return false;
  }