Skip to content

Instantly share code, notes, and snippets.

@gavvvr
Last active January 1, 2023 13:30
Show Gist options
  • Save gavvvr/bc3c384a63cabfa455d2c84fd11b5844 to your computer and use it in GitHub Desktop.
Save gavvvr/bc3c384a63cabfa455d2c84fd11b5844 to your computer and use it in GitHub Desktop.
Gradle task to collect all jUnit XML test reports from all submodules
// The Gradle's test-report-aggregation collects only html reports in a single place and ignores XML reports
// Here is the custom task to collect all jUnit xml reports in a single place
tasks.register<Copy>("testCollectjUnitXmlReports") {
val allTestTasks = rootProject
.subprojects
.flatMap { it.tasks.withType<Test>() }
val allJunitXmlLocations = allTestTasks
.map { it.reports.junitXml.outputLocation.asFile.get() }
from(*allJunitXmlLocations.toTypedArray())
into(rootProject.layout.buildDirectory.dir("test-results/test"))
include("*.xml")
mustRunAfter(*allTestTasks.toTypedArray())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment