What is the `test-report-aggregation` plugin in Gradle and what problem does it solve in a multi-project build?
answer
- core plugin, no version
- one HTML report from many subprojects
- testAggregateTestReport task
- testReportAggregation configuration
- variant-aware, not file paths
basics
~10 sIt's a core Gradle plugin that merges the test results of multiple subprojects into a single combined HTML report, so you don't have to open each subproject's report separately.
solid answer
~40 s`test-report-aggregation` is a built-in Gradle plugin (no external dependency) that collects the test results produced across many subprojects and renders one consolidated HTML report. In a multi-project build, each subproject normally produces its own `build/reports/tests/test/index.html`; reviewing them one by one is tedious and gives no project-wide pass/fail view. You apply the plugin (usually on an aggregating project such as a dedicated `test-report` project or the application project), it adds a `testAggregateTestReport` task, and running it gathers the binary test result data from every project it depends on and writes a single HTML report under `build/reports/tests/...`. It uses variant-aware dependency resolution to find result data, so it only needs project dependencies declared, not manual wiring of file paths.
code
kotlin · 10 linesplugins {
id("test-report-aggregation")
}
dependencies {
testReportAggregation(project(":service-a"))
testReportAggregation(project(":service-b"))
}
// Run: ./gradlew testAggregateTestReportgo deeper
Know it produces one combined test report across subprojects and adds a testAggregateTestReport task.
Explain it merges binary result data via project dependencies on a testReportAggregation configuration, not file copying.
Discuss applying it on a dedicated aggregation project and how variant-aware resolution supplies the result data.
Position it within a standardized multi-project reporting strategy alongside jacoco-report-aggregation and a CI artifact convention across teams.
## The problem In a Gradle multi-project build, every project that runs tests produces its own report. By default `Test` tasks write: - Binary result data to `build/test-results/test/` (used by tooling) - A human HTML report to `build/reports/tests/test/index.html` With ten subprojects you get ten separate HTML reports and no single "did everything pass?" view. CI dashboards and humans both want one artifact. ## What the plugin does The **`test-report-aggregation`** plugin is a *core* Gradle plugin (ships with the distribution — no `dependencies {}` entry, no version). Applying it: 1. Adds a resolvable configuration that knows how to ask other projects for their *test result data* (not their HTML — the raw binary results). 2. Registers a task named **`testAggregateTestReport`** of type `AggregateTestReport`. 3. Wires that task to merge the collected binary results into ONE HTML report, typically at `build/reports/tests/unit-test/aggregated-results/index.html`. ## How it finds the data It relies on **variant-aware resolution**. You declare ordinary project dependencies, and the plugin requests the `test-results` outgoing variant from each. This is why you don't hand-wire file paths — Gradle's dependency graph carries the result data via attributes. ```kotlin plugins { id("test-report-aggregation") } dependencies { testReportAggregation(project(":service-a")) testReportAggregation(project(":service-b")) } reporting { reports { val testAggregateTestReport by getting(AggregateTestReport::class) { testSuiteName = "test" } } } ``` Run `./gradlew testAggregateTestReport` and you get one combined report. ## Where to apply it A common pattern is a dedicated project (e.g. `:test-report`) that depends on all the others purely to aggregate. The `jvm-test-suite` and `java` plugins also integrate so the `application` or `java` plugin's project can host the aggregation. The sibling **`jacoco-report-aggregation`** plugin does the same idea for coverage.
- Is `test-report-aggregation` a third-party plugin you add a version for?No. It is a core Gradle plugin bundled with the distribution, so you apply it by id with no version and no buildscript dependency.
- What task name does it add?`testAggregateTestReport` (of type `AggregateTestReport`), which produces the merged HTML report.
Like a teacher collecting every student's individual quiz sheet and stapling them into one gradebook instead of leaving ten loose papers on the desk.
saying these in an interview costs you the question
- Saying you must manually copy each subproject's HTML into one folder — the plugin merges binary result data, not HTML.
- Treating it as a community plugin that needs a version number.