diff --git a/build.gradle.kts b/build.gradle.kts index bb66464bcb7..c5387e7e8e2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -144,6 +144,81 @@ moduleGraphConfig { heading.set("#### Dependency Graph") } +tasks.register("runAllUnitTests") { + description = "Runs all Unit Tests." + + rootProject.subprojects { + if (tasks.findByName("testDebugUnitTest") != null) { + println("Adding $name to runUnitTests") + dependsOn(":$name:testDebugUnitTest") + } + if (name != "cryptography") { + if (tasks.findByName("jvmTest") != null) { + println("Adding $name to jvmTest") + dependsOn(":$name:jvmTest") + } + } + } +} + +tasks.register("aggregateTestResults") { + description = "Aggregates all Unit Test results into a single report." + + doLast { + val testResultsDir = rootProject.layout.buildDirectory.dir("testResults").get().asFile + testResultsDir.deleteRecursively() + testResultsDir.mkdirs() + + val indexHtmlFile = File(testResultsDir, "index.html") + indexHtmlFile.writeText( + """ + + + Aggregated Test Reports + + +

Aggregated Test Reports

+ + + + """.trimIndent() + ) + + // Print the location of the aggregated test results directory + // relative to the current terminal working dir + val currentWorkingDir = File(System.getProperty("user.dir")) + val relativePath = testResultsDir.relativeTo(currentWorkingDir).path + println("Aggregated test reports are available at: $relativePath") + } +} + tasks.wrapper { distributionType = Wrapper.DistributionType.ALL }