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() + ".");
    }
  }
  public void execute(final Test testTask, TestResultProcessor testResultProcessor) {
    final TestFramework testFramework = testTask.getTestFramework();
    final WorkerTestClassProcessorFactory testInstanceFactory = testFramework.getProcessorFactory();
    final Factory<TestClassProcessor> forkingProcessorFactory =
        new Factory<TestClassProcessor>() {
          public TestClassProcessor create() {
            return new ForkingTestClassProcessor(
                workerFactory,
                testInstanceFactory,
                testTask,
                testTask.getClasspath(),
                testFramework.getWorkerConfigurationAction());
          }
        };
    Factory<TestClassProcessor> reforkingProcessorFactory =
        new Factory<TestClassProcessor>() {
          public TestClassProcessor create() {
            return new RestartEveryNTestClassProcessor(
                forkingProcessorFactory, testTask.getForkEvery());
          }
        };

    TestClassProcessor processor =
        new MaxNParallelTestClassProcessor(
            testTask.getMaxParallelForks(), reforkingProcessorFactory, actorFactor);

    final FileTree testClassFiles = testTask.getCandidateClassFiles();

    Runnable detector;
    if (testTask.isScanForTestClasses()) {
      TestFrameworkDetector testFrameworkDetector = testTask.getTestFramework().getDetector();
      testFrameworkDetector.setTestClassesDirectory(testTask.getTestClassesDir());
      testFrameworkDetector.setTestClasspath(testTask.getClasspath());
      detector = new DefaultTestClassScanner(testClassFiles, testFrameworkDetector, processor);
    } else {
      detector = new DefaultTestClassScanner(testClassFiles, null, processor);
    }
    new TestMainAction(detector, processor, testResultProcessor, new TrueTimeProvider()).run();
  }
Exemple #3
0
 public TestFrameworkOptions options(Closure testFrameworkConfigure) {
   TestFrameworkOptions options = getTestFramework().getOptions();
   ConfigureUtil.configure(testFrameworkConfigure, testFramework.getOptions());
   return options;
 }