Skip to content

Commit 8726693

Browse files
committed
display test results during testing
1 parent 02bc21f commit 8726693

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

test/build.gradle

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,35 @@ android.applicationVariants.all { variant ->
2828
tasks["compile${productFlavor}${buildType}UnitTestSources"].dependsOn(tasks["merge${productFlavor}${buildType}Assets"])
2929
}
3030

31+
// display test progress http://stackoverflow.com/a/36130467/999458
32+
tasks.withType(Test) {
33+
testLogging {
34+
// set options for log level LIFECYCLE
35+
events "passed", "skipped", "failed", "standardOut"
36+
showExceptions true
37+
exceptionFormat "full"
38+
showCauses true
39+
showStackTraces true
40+
41+
// set options for log level DEBUG and INFO
42+
debug {
43+
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
44+
exceptionFormat "full"
45+
}
46+
info.events = debug.events
47+
info.exceptionFormat = debug.exceptionFormat
48+
49+
afterSuite { desc, result ->
50+
if (!desc.parent) { // will match the outermost suite
51+
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
52+
def startItem = '| ', endItem = ' |'
53+
def repeatLength = startItem.length() + output.length() + endItem.length()
54+
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
55+
}
56+
}
57+
}
58+
}
59+
3160
dependencies {
3261
compile project(':library')
3362
testCompile 'org.slf4j:slf4j-simple:1.7.21'

0 commit comments

Comments
 (0)