problem: hard to find failing tests on CI
This commit is contained in:
36
build.gradle
36
build.gradle
@@ -125,7 +125,7 @@ compileTestKotlin {
|
|||||||
|
|
||||||
test {
|
test {
|
||||||
jvmArgs '-ea'
|
jvmArgs '-ea'
|
||||||
testLogging.showStandardStreams = true
|
testLogging.showStandardStreams = false
|
||||||
testLogging.exceptionFormat = 'full'
|
testLogging.exceptionFormat = 'full'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,3 +200,37 @@ task generateVersion() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show the list of failed tests and output only for them, helpful for CI
|
||||||
|
ext.failedTests = []
|
||||||
|
tasks.withType(Test) {
|
||||||
|
def stdout = new LinkedList<String>()
|
||||||
|
beforeTest { TestDescriptor td ->
|
||||||
|
stdout.clear()
|
||||||
|
}
|
||||||
|
onOutput { TestDescriptor td, TestOutputEvent toe ->
|
||||||
|
stdout.addAll(toe.getMessage().split('(?m)$'))
|
||||||
|
while (stdout.size() > 100) {
|
||||||
|
stdout.remove()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
afterTest { TestDescriptor descriptor, TestResult result ->
|
||||||
|
if(result.resultType == org.gradle.api.tasks.testing.TestResult.ResultType.FAILURE){
|
||||||
|
failedTests << "${descriptor.className} > ${descriptor.name}"
|
||||||
|
if (!stdout.isEmpty()) {
|
||||||
|
println("-------- ${descriptor.className} > ${descriptor.name} OUTPUT ".padRight(120, "-"))
|
||||||
|
stdout.each { print(it) }
|
||||||
|
println("================".padRight(120, "="))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gradle.buildFinished {
|
||||||
|
if(!failedTests.empty){
|
||||||
|
println "Failed tests for ${project.name}:"
|
||||||
|
failedTests.each { failedTest ->
|
||||||
|
println failedTest
|
||||||
|
}
|
||||||
|
println ""
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user