From 3fff60f12538298fb654ad050d72b2b26a68bcae Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Fri, 6 Aug 2021 18:22:52 +0200 Subject: [PATCH] build: added fancy test logging --- Server/build.gradle | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Server/build.gradle b/Server/build.gradle index b996a67..a2013fa 100644 --- a/Server/build.gradle +++ b/Server/build.gradle @@ -16,6 +16,50 @@ test { maxParallelForks = 1 } + + +// Fancy live test output (from https://stackoverflow.com/questions/3963708/gradle-how-to-display-test-results-in-the-console-in-real-time) + +import org.gradle.api.tasks.testing.logging.TestExceptionFormat +import org.gradle.api.tasks.testing.logging.TestLogEvent + +tasks.withType(Test) { + testLogging { + // set options for log level LIFECYCLE + events TestLogEvent.FAILED, + TestLogEvent.PASSED, + TestLogEvent.SKIPPED + // TestLogEvent.STANDARD_OUT + exceptionFormat TestExceptionFormat.FULL + showExceptions true + showCauses true + showStackTraces true + + // set options for log level DEBUG and INFO + debug { + events TestLogEvent.STARTED, + TestLogEvent.FAILED, + TestLogEvent.PASSED, + TestLogEvent.SKIPPED, + TestLogEvent.STANDARD_ERROR + TestLogEvent.STANDARD_OUT + exceptionFormat TestExceptionFormat.FULL + } + // info.events = debug.events + // info.exceptionFormat = debug.exceptionFormat + + afterSuite { desc, result -> + if (!desc.parent) { // will match the outermost suite + def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)" + def startItem = '| ', endItem = ' |' + def repeatLength = startItem.length() + output.length() + endItem.length() + println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength)) + } + } + } +} + + jacocoTestReport { reports { html.enabled true