Skip to content

Instantly share code, notes, and snippets.

@falkorichter
Created June 11, 2021 10:25
Show Gist options
  • Save falkorichter/48d25606541fae91385ed61e3a382ccd to your computer and use it in GitHub Desktop.
Save falkorichter/48d25606541fae91385ed61e3a382ccd to your computer and use it in GitHub Desktop.
better test description
tasks.withType(Test) {
def failedTests = []
testLogging {
events TestLogEvent.FAILED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT,
TestLogEvent.STANDARD_ERROR
}
afterTest { TestDescriptor descriptor, TestResult result ->
if(result.resultType == org.gradle.api.tasks.testing.TestResult.ResultType.FAILURE){
failedTests << ["${descriptor.className}::${descriptor.name}"]
}
}
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))
println('\n Failed Tests:\n' + failedTests.join(", "))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment