Exemple #1
0
  @TaskAction
  public void executeTests() {
    for (LogLevel level : LogLevel.values()) {
      if (!LOGGER.isEnabled(level)) {
        continue;
      }
      TestLogging levelLogging = testLogging.get(level);
      TestExceptionFormatter exceptionFormatter = getExceptionFormatter(testLogging);
      TestEventLogger eventLogger =
          new TestEventLogger(outputListener, level, levelLogging, exceptionFormatter);
      addTestListener(eventLogger);
      addTestOutputListener(eventLogger);
    }

    ProgressLoggerFactory progressLoggerFactory = getServices().get(ProgressLoggerFactory.class);
    TestCountLogger testCountLogger = new TestCountLogger(progressLoggerFactory);
    addTestListener(testCountLogger);

    TestResultProcessor resultProcessor =
        new TestListenerAdapter(
            getTestListenerBroadcaster().getSource(), testOutputListenerBroadcaster.getSource());
    testExecuter.execute(this, resultProcessor);

    testFramework.report();

    testFramework = null;

    if (!getIgnoreFailures() && testCountLogger.hadFailures()) {
      throw new GradleException(
          "There were failing tests. See the report at " + getTestReportUrl() + ".");
    }
  }