use of org.gradle.api.internal.tasks.testing.junit.result.TestClassResult in project gradle by gradle.
the class AbstractTestTask method executeTests.
@TaskAction
public void executeTests() {
LogLevel currentLevel = determineCurrentLogLevel();
TestLogging levelLogging = getTestLogging().get(currentLevel);
TestExceptionFormatter exceptionFormatter = getExceptionFormatter(levelLogging);
TestEventLogger eventLogger = new TestEventLogger(getTextOutputFactory(), currentLevel, levelLogging, exceptionFormatter);
addTestListener(eventLogger);
addTestOutputListener(eventLogger);
TestExecutionSpec executionSpec = createTestExecutionSpec();
final File binaryResultsDir = getBinaryResultsDirectory().getAsFile().get();
FileSystemOperations fs = getFileSystemOperations();
fs.delete(new Action<DeleteSpec>() {
@Override
public void execute(DeleteSpec spec) {
spec.delete(binaryResultsDir);
}
});
binaryResultsDir.mkdirs();
Map<String, TestClassResult> results = new HashMap<String, TestClassResult>();
TestOutputStore testOutputStore = new TestOutputStore(binaryResultsDir);
TestOutputStore.Writer outputWriter = testOutputStore.writer();
TestReportDataCollector testReportDataCollector = new TestReportDataCollector(results, outputWriter);
addTestListener(testReportDataCollector);
addTestOutputListener(testReportDataCollector);
TestCountLogger testCountLogger = new TestCountLogger(getProgressLoggerFactory());
addTestListener(testCountLogger);
getTestListenerInternalBroadcaster().add(new TestListenerAdapter(testListenerBroadcaster.getSource(), getTestOutputListenerBroadcaster().getSource()));
ProgressLogger parentProgressLogger = getProgressLoggerFactory().newOperation(AbstractTestTask.class);
parentProgressLogger.setDescription("Test Execution");
parentProgressLogger.started();
TestWorkerProgressListener testWorkerProgressListener = new TestWorkerProgressListener(getProgressLoggerFactory(), parentProgressLogger);
getTestListenerInternalBroadcaster().add(testWorkerProgressListener);
TestExecuter<TestExecutionSpec> testExecuter = Cast.uncheckedNonnullCast(createTestExecuter());
TestListenerInternal resultProcessorDelegate = getTestListenerInternalBroadcaster().getSource();
if (failFast) {
resultProcessorDelegate = new FailFastTestListenerInternal(testExecuter, resultProcessorDelegate);
}
TestResultProcessor resultProcessor = new StateTrackingTestResultProcessor(resultProcessorDelegate);
try {
testExecuter.execute(executionSpec, resultProcessor);
} finally {
parentProgressLogger.completed();
testWorkerProgressListener.completeAll();
testListenerBroadcaster.removeAll();
getTestOutputListenerBroadcaster().removeAll();
getTestListenerInternalBroadcaster().removeAll();
outputWriter.close();
}
new TestResultSerializer(binaryResultsDir).write(results.values());
createReporting(results, testOutputStore);
handleCollectedResults(testCountLogger);
}
use of org.gradle.api.internal.tasks.testing.junit.result.TestClassResult in project gradle by gradle.
the class Test method getPreviousFailedTestClasses.
private Set<String> getPreviousFailedTestClasses() {
TestResultSerializer serializer = new TestResultSerializer(getBinaryResultsDirectory().getAsFile().get());
if (serializer.isHasResults()) {
final Set<String> previousFailedTestClasses = new HashSet<String>();
serializer.read(new Action<TestClassResult>() {
@Override
public void execute(TestClassResult testClassResult) {
if (testClassResult.getFailuresCount() > 0) {
previousFailedTestClasses.add(testClassResult.getClassName());
}
}
});
return previousFailedTestClasses;
} else {
return Collections.emptySet();
}
}
Aggregations