Created
June 11, 2021 10:25
-
-
Save falkorichter/48d25606541fae91385ed61e3a382ccd to your computer and use it in GitHub Desktop.
better test description
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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