Build: Increase the number of failed tests shown in test summary

We had increased this in maven, but it was lost in the transition to
gradle. This change adds it as a configurable setting the the logger for
randomized testing and bumps it to 25.
This commit is contained in:
Ryan Ernst 2015-11-30 13:40:39 -08:00
parent cc627e41cc
commit 4bb1eed766
3 changed files with 14 additions and 7 deletions

View File

@ -1,5 +1,6 @@
package com.carrotsearch.gradle.junit4 package com.carrotsearch.gradle.junit4
import org.gradle.api.tasks.Input
import org.gradle.util.ConfigureUtil import org.gradle.util.ConfigureUtil
class TestLoggingConfiguration { class TestLoggingConfiguration {
@ -20,6 +21,10 @@ class TestLoggingConfiguration {
SlowTestsConfiguration slowTests = new SlowTestsConfiguration() SlowTestsConfiguration slowTests = new SlowTestsConfiguration()
StackTraceFiltersConfiguration stackTraceFilters = new StackTraceFiltersConfiguration() StackTraceFiltersConfiguration stackTraceFilters = new StackTraceFiltersConfiguration()
/** Summarize the first N failures at the end of the test. */
@Input
int showNumFailuresAtEnd = 3 // match TextReport default
void slowTests(Closure closure) { void slowTests(Closure closure) {
ConfigureUtil.configure(closure, slowTests) ConfigureUtil.configure(closure, slowTests)
} }
@ -31,4 +36,8 @@ class TestLoggingConfiguration {
void outputMode(String mode) { void outputMode(String mode) {
outputMode = mode.toUpperCase() as OutputMode outputMode = mode.toUpperCase() as OutputMode
} }
void showNumFailuresAtEnd(int n) {
showNumFailuresAtEnd = n
}
} }

View File

@ -48,9 +48,6 @@ class TestReportLogger extends TestsSummaryEventListener implements AggregatedEv
/** Format line for JVM ID string. */ /** Format line for JVM ID string. */
String jvmIdFormat String jvmIdFormat
/** Summarize the first N failures at the end. */
int showNumFailuresAtEnd = 3
/** Output stream that logs messages to the given logger */ /** Output stream that logs messages to the given logger */
LoggingOutputStream outStream LoggingOutputStream outStream
LoggingOutputStream errStream LoggingOutputStream errStream
@ -110,13 +107,13 @@ class TestReportLogger extends TestsSummaryEventListener implements AggregatedEv
@Subscribe @Subscribe
void onQuit(AggregatedQuitEvent e) throws IOException { void onQuit(AggregatedQuitEvent e) throws IOException {
if (showNumFailuresAtEnd > 0 && !failedTests.isEmpty()) { if (config.showNumFailuresAtEnd > 0 && !failedTests.isEmpty()) {
List<Description> sublist = this.failedTests List<Description> sublist = this.failedTests
StringBuilder b = new StringBuilder() StringBuilder b = new StringBuilder()
b.append('Tests with failures') b.append('Tests with failures')
if (sublist.size() > showNumFailuresAtEnd) { if (sublist.size() > config.showNumFailuresAtEnd) {
sublist = sublist.subList(0, showNumFailuresAtEnd) sublist = sublist.subList(0, config.showNumFailuresAtEnd)
b.append(" (first " + showNumFailuresAtEnd + " out of " + failedTests.size() + ")") b.append(" (first " + config.showNumFailuresAtEnd + " out of " + failedTests.size() + ")")
} }
b.append(':\n') b.append(':\n')
for (Description description : sublist) { for (Description description : sublist) {

View File

@ -365,6 +365,7 @@ class BuildPlugin implements Plugin<Project> {
enableSystemAssertions false enableSystemAssertions false
testLogging { testLogging {
showNumFailuresAtEnd 25
slowTests { slowTests {
heartbeat 10 heartbeat 10
summarySize 5 summarySize 5