# Aggregating test results of an application/distribution (Incubating) Sample

version 8.1

- Groovy DSL

- Kotlin DSL

| You can open this sample inside an IDE using the IntelliJ native importer or Eclipse Buildship.

This sample shows how to aggregate test results across multiple Java subprojects. The test-report-aggregation plugin provides this ability when applied to the distribution project, such as an Android application or WAR subproject.

The project in this example contains three projects: `application`, `list` and `utilities`. All three projects apply the `java` plugin, and `application` consumes both `list` and `utilities` on its implementation configuration. The `application` subproject is the final distribution of this software project, and applies `test-report-aggregation` to perform the test result aggregation.

| The Test Report Aggregation plugin does not currently work with the `com.android.application` plugin.

application/build.gradle.kts

    plugins {
        id("myproject.java-conventions")
        application
        id("test-report-aggregation") (1)
    }

    dependencies {
        implementation(project(":list"))
        implementation(project(":utilities"))
    }

    application {
        mainClass.set("org.gradle.sample.Main")
    }

    tasks.check {
        dependsOn(tasks.named<TestReport>("testAggregateTestReport")) (2)
    }

application/build.gradle

    plugins {
        id 'myproject.java-conventions'
        id 'application'
        id 'test-report-aggregation' (1)
    }

    dependencies {
        implementation project(':list')
        implementation project(':utilities')
    }

    application {
        mainClass = 'org.gradle.sample.Main'
    }

    tasks.named('check') {
        dependsOn tasks.named('testAggregateTestReport', TestReport) (2)
    }

The `application` project requires no additional configuration if the `jvm-test-suite` plugin is present.

1 | Apply the `test-report-aggregation` plugin
2 | Optional: make aggregate test report generation part of the 'check' lifecycle phase

The aggregation logic does not automatically inspect all subprojects for test results. Instead, the direct and transitive project dependencies of the distribution project’s runtime classpath are selected for potential aggregation.

For the default test suite named 'test', no additional configuration is necessary. The aggregated reports and their backing tasks of type `TestReport` are synthesized based on the test suites existing in the `application` project. Test suites having identical `testType` properties will be aggregated.

Running the tests and generate the report:

    $ ./gradlew testAggregateTestReport

    BUILD SUCCESSFUL
    24 actionable tasks: 24 executed

The aggregated HTML report can now be found under `application/build/reports/tests/unit-tests/aggregated-results`.

For more information, see Testing in Java project chapter.