Skip to content

Instantly share code, notes, and snippets.

@orip
Created February 14, 2013 09:52
Show Gist options
  • Save orip/4951642 to your computer and use it in GitHub Desktop.
Save orip/4951642 to your computer and use it in GitHub Desktop.
Print Gradle test results to console
/*
Sample output:
> gradle test ruby-1.9.3-p194 testing_with_gradle 9179829 ✗
...
:test
Results: SUCCESS (84 tests, 74 successes, 0 failures, 10 skipped)
*/
test {
testLogging {
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
println "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
}
}
}
}
@siboxd
Copy link

siboxd commented Nov 25, 2019

For a buiild.gradle.kts with gradle 6.0.1, you can use:

tasks.withType<AbstractTestTask> {
    afterSuite(KotlinClosure2({ desc: TestDescriptor, result: TestResult ->
        if (desc.parent == null) { // will match the outermost suite
            println("Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)")
        }
    }))
}

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