Skip to content

Instantly share code, notes, and snippets.

@ylogx
Created March 21, 2016 12:02
Show Gist options
  • Save ylogx/7ec674fe2f73604d4dea to your computer and use it in GitHub Desktop.
Save ylogx/7ec674fe2f73604d4dea to your computer and use it in GitHub Desktop.
Fancy Print test results with gradle
tasks.withType(Test) {
testLogging {
// set options for log level LIFECYCLE
events "passed", "skipped", "failed", "standardOut"
showExceptions true
exceptionFormat "short"
showCauses true
showStackTraces true
// set options for log level DEBUG and INFO
debug {
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
exceptionFormat "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} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
}
@ylogx
Copy link
Author

ylogx commented Mar 21, 2016

Fancy Test Results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment