Search in sources :

Example 1 with DefaultTestReport

use of org.gradle.api.internal.tasks.testing.report.DefaultTestReport in project gradle by gradle.

the class AbstractTestTask method createReporting.

private void createReporting(Map<String, TestClassResult> results, TestOutputStore testOutputStore) {
    TestResultsProvider testResultsProvider = new InMemoryTestResultsProvider(results.values(), testOutputStore);
    try {
        if (testReporter == null) {
            testReporter = new DefaultTestReport(getBuildOperationExecutor());
        }
        JUnitXmlReport junitXml = reports.getJunitXml();
        if (junitXml.isEnabled()) {
            TestOutputAssociation outputAssociation = junitXml.isOutputPerTestCase() ? TestOutputAssociation.WITH_TESTCASE : TestOutputAssociation.WITH_SUITE;
            Binary2JUnitXmlReportGenerator binary2JUnitXmlReportGenerator = new Binary2JUnitXmlReportGenerator(junitXml.getDestination(), testResultsProvider, outputAssociation, getBuildOperationExecutor(), getInetAddressFactory().getHostname());
            binary2JUnitXmlReportGenerator.generate();
        }
        DirectoryReport html = reports.getHtml();
        if (!html.isEnabled()) {
            getLogger().info("Test report disabled, omitting generation of the HTML test report.");
        } else {
            testReporter.generateReport(testResultsProvider, html.getDestination());
        }
    } finally {
        CompositeStoppable.stoppable(testResultsProvider).stop();
        testReporter = null;
    }
}
Also used : TestOutputAssociation(org.gradle.api.internal.tasks.testing.junit.result.TestOutputAssociation) Binary2JUnitXmlReportGenerator(org.gradle.api.internal.tasks.testing.junit.result.Binary2JUnitXmlReportGenerator) InMemoryTestResultsProvider(org.gradle.api.internal.tasks.testing.junit.result.InMemoryTestResultsProvider) TestResultsProvider(org.gradle.api.internal.tasks.testing.junit.result.TestResultsProvider) InMemoryTestResultsProvider(org.gradle.api.internal.tasks.testing.junit.result.InMemoryTestResultsProvider) DefaultTestReport(org.gradle.api.internal.tasks.testing.report.DefaultTestReport) DirectoryReport(org.gradle.api.reporting.DirectoryReport)

Example 2 with DefaultTestReport

use of org.gradle.api.internal.tasks.testing.report.DefaultTestReport in project gradle by gradle.

the class TestReport method generateReport.

@TaskAction
void generateReport() {
    TestResultsProvider resultsProvider = createAggregateProvider();
    try {
        if (resultsProvider.isHasResults()) {
            DefaultTestReport testReport = new DefaultTestReport(getBuildOperationExecutor());
            testReport.generateReport(resultsProvider, getDestinationDir());
        } else {
            getLogger().info("{} - no binary test results found in dirs: {}.", getPath(), getTestResultDirs().getFiles());
            setDidWork(false);
        }
    } finally {
        stoppable(resultsProvider).stop();
    }
}
Also used : TestResultsProvider(org.gradle.api.internal.tasks.testing.junit.result.TestResultsProvider) AggregateTestResultsProvider(org.gradle.api.internal.tasks.testing.junit.result.AggregateTestResultsProvider) BinaryResultBackedTestResultsProvider(org.gradle.api.internal.tasks.testing.junit.result.BinaryResultBackedTestResultsProvider) DefaultTestReport(org.gradle.api.internal.tasks.testing.report.DefaultTestReport) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

TestResultsProvider (org.gradle.api.internal.tasks.testing.junit.result.TestResultsProvider)2 DefaultTestReport (org.gradle.api.internal.tasks.testing.report.DefaultTestReport)2 AggregateTestResultsProvider (org.gradle.api.internal.tasks.testing.junit.result.AggregateTestResultsProvider)1 Binary2JUnitXmlReportGenerator (org.gradle.api.internal.tasks.testing.junit.result.Binary2JUnitXmlReportGenerator)1 BinaryResultBackedTestResultsProvider (org.gradle.api.internal.tasks.testing.junit.result.BinaryResultBackedTestResultsProvider)1 InMemoryTestResultsProvider (org.gradle.api.internal.tasks.testing.junit.result.InMemoryTestResultsProvider)1 TestOutputAssociation (org.gradle.api.internal.tasks.testing.junit.result.TestOutputAssociation)1 DirectoryReport (org.gradle.api.reporting.DirectoryReport)1 TaskAction (org.gradle.api.tasks.TaskAction)1