vault backup: 2025-12-10 11:37:35

This commit is contained in:
2023-05-15 17:16:05 +02:00
committed by Thomas Peetz
parent 91bf72fc87
commit 73f2162ddf
6049 changed files with 513094 additions and 227748 deletions
@@ -0,0 +1,122 @@
---
title: The Test Report Aggregation Plugin
source: https://docs.gradle.org/current/userguide/test_report_aggregation_plugin.html
tags:
- IT/Development/Gradle
---
The Test Report Aggregation plugin (plugin id: `test-report-aggregation`) provides tasks and configurations used to aggregate the results of multiple [Test](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html) task invocations (potentially spanning multiple Gradle projects) into a single HTML report.
## [](#sec:test_report_aggregation_usage)[Usage](#sec:test_report_aggregation_usage)
To use the Test Report Aggregation plugin, include the following in your build script:
plugins {
id 'test-report-aggregation'
}
plugins {
id("test-report-aggregation")
}
Note that this plugin takes no action unless applied in concert with the [JVM Test Suite Plugin](https://docs.gradle.org/current/userguide/jvm_test_suite_plugin.html#jvm_test_suite_plugin). The [Java Plugin](https://docs.gradle.org/current/userguide/java_plugin.html#java_plugin) automatically applies the JVM Test Suite Plugin.
There are now two ways to collect test results across multiple subprojects:
1. From the distributions project, such as an application or WAR subproject → [distribution sample](https://docs.gradle.org/current/samples/sample_jvm_multi_project_with_test_aggregation_distribution.html)
2. Using a standalone project to specify subprojects → [standalone sample](https://docs.gradle.org/current/samples/sample_jvm_multi_project_with_test_aggregation_standalone.html)
Example 2 could also be used to aggregate results via the root project.
| | |
| --- | --- |
| | The Test Report Aggregation plugin does not currently work with the `com.android.application` plugin. |
## [](#sec:test_report_aggregation_tasks)[Tasks](#sec:test_report_aggregation_tasks)
When the project also applies the `jvm-test-suite` plugin, the following tasks are added for each test suite:
`testSuiteAggregateTestReport` — [TestReport](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.TestReport.html)
*Depends on*: Artifacts of variants matching the below attributes
Collects variants of direct and transitive project dependencies via the `testReportAggregation` configuration. The following Attributes will be matched:
```
- org.gradle.category = verification
(1)
- org.gradle.testsuite.type = unit-test
(2)
- org.gradle.verificationtype = test-results
(3)
```
| | |
| --- | --- |
| **1** | Category attribute; value is fixed. |
| **2** | TestSuiteType attribute; value is derived from [JvmTestSuite#getTestType()](https://docs.gradle.org/current/javadoc/org/gradle/api/plugins/jvm/JvmTestSuite.html#getTestType--). |
| **3** | VerificationType attribute; value is fixed. |
More information about the variants produced by test execution are available in the [Outgoing Variants](https://docs.gradle.org/current/userguide/jvm_test_suite_plugin.html#sec:outgoing_variants) section of the JVM Test Suite Plugin documentation.
## [](#reports)[Reports](#reports)
| | |
| --- | --- |
| | By default, Gradle stops executing tasks when any task fails — including test failures. To ensure that your builds always generate aggregation reports, specify the `--continue` option in your Gradle command. For more information, see [continuing the build when a failure occurs](https://docs.gradle.org/current/userguide/command_line_interface.html#sec:continue_build_on_failure). |
### [](#automatic_report_creation)[Automatic report creation](#automatic_report_creation)
When the project also applies the `jvm-test-suite` plugin, the following reporting objects are added for each test suite:
### [](#manual_report_creation)[Manual report creation](#manual_report_creation)
When the project does not apply the `jvm-test-suite` plugin, you must manually register one or more reports:
Example 1. [Create a reporting container](#ex-create-a-reporting-container)
`Kotlin``Groovy`
build.gradle.kts
```
reporting { reports { val testAggregateTestReport by creating(AggregateTestReport::class)
{
(1) testType.set(TestSuiteType.UNIT_TEST)
}
}
}
```
| | |
| --- | --- |
| **1** | Creates a report named `testAggregateTestReport` of type `AggregateTestReport`. For convenience, sets `TestType` using a constant value from the [TestSuiteType](https://docs.gradle.org/current/javadoc/org/gradle/api/attributes/TestSuiteType.html) class. Any String value is acceptable. |
Report creation automatically creates backing tasks to aggregate by the given test suite type value.
## [](#sec:dependency_management)[Dependency management](#sec:dependency_management)
The Test Report Aggregation plugin adds the following dependency configurations:
| | |
| --- | --- |Table 1. Test Report Aggregation plugin - dependency configurations
| Name | Meaning |
| --- | --- |
| `testReportAggregation` | The configuration used to declare all project dependencies having test result data to be aggregated. |
| `aggregateTestReportResults` | Consumes the project dependencies from the `testReportAggregation` configuration using [variant-aware matching](https://docs.gradle.org/current/userguide/variant_model.html#sec:variant-aware-matching) to find the appropriate test suite type. |
It is not necessary to explicitly add dependencies to the `testReportAggregation` configuration if the project also applies the `jvm-test-suite` plugin.