+}
+
+/*
+ * adapted from https://medium.com/@wasyl/pretty-tests-summary-in-gradle-744804dd676c
+ * to summarise test results from all Test tasks
+ */
+/* START of test tasks results summary */
+import groovy.time.TimeCategory
+import org.gradle.api.tasks.testing.logging.TestExceptionFormat
+import org.gradle.api.tasks.testing.logging.TestLogEvent
+
+rootProject.ext.testsResults = [] // Container for tests summaries
+
+tasks.withType(Test).matching {t -> t.getName().startsWith("testTask")}.all { testTask ->
+
+ // from original test task
+ if (useClover) {
+ dependsOn cloverClasses
+ } else { //?
+ dependsOn testClasses //?
+ }
+
+ // run main tests first
+ if (!testTask.name.equals("testTask0"))
+ testTask.mustRunAfter "testTask0"
+
+ testTask.testLogging { logging ->
+ events TestLogEvent.FAILED,
+ TestLogEvent.SKIPPED,
+ TestLogEvent.STANDARD_OUT,
+ TestLogEvent.STANDARD_ERROR
+
+ exceptionFormat TestExceptionFormat.FULL
+ showExceptions true
+ showCauses true
+ showStackTraces true
+ }
+
+ ignoreFailures = true // Always try to run all tests for all modules
+
+ afterSuite { desc, result ->
+
+ if (desc.parent) return // Only summarize results for whole modules
+
+ String summary = "${testTask.project.name}:${testTask.name} results: ${result.resultType} " +
+ "(" +
+ "${result.testCount} tests, " +
+ "${result.successfulTestCount} successes, " +
+ "${result.failedTestCount} failures, " +
+ "${result.skippedTestCount} skipped" +
+ ") " +
+ "in ${TimeCategory.minus(new Date(result.endTime), new Date(result.startTime))}" +
+ "\n" +
+ "Report file: ${testTask.reports.html.entryPoint}"
+
+ // Add reports in `testsResults`, keep failed suites at the end
+ if (result.resultType == TestResult.ResultType.SUCCESS) {
+ rootProject.ext.testsResults.add(0, summary)
+ } else {
+ rootProject.ext.testsResults += summary
+ }
+
+ if (result.resultType == TestResult.ResultType.FAILURE) {
+ testsFailed = true
+ }
+ }