Skip to content

Commit f6f5831

Browse files
committed
Add failed-test recap for runner output
Print each failed test case as '<suite-file> <test-case-id> (<test-case-description>)' above the total summary section in all verbosity modes.
1 parent 735928f commit f6f5831

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

cmd/runner/main.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func main() {
6767
totalFailed := 0
6868
totalTests := 0
6969
loggedTimeout := false
70+
failedTestLines := make([]string, 0)
7071

7172
for suiteIdx, testFile := range testFiles {
7273
// Load test suite from embedded FS
@@ -90,6 +91,7 @@ func main() {
9091
// Run suite
9192
result := testRunner.RunTestSuite(ctx, *suite, verbosity)
9293
printResults(suite, result, verbosity)
94+
failedTestLines = append(failedTestLines, collectFailedTestLines(suite, result)...)
9395

9496
totalPassed += result.PassedTests
9597
totalFailed += result.FailedTests
@@ -101,6 +103,15 @@ func main() {
101103
}
102104
}
103105

106+
if len(failedTestLines) > 0 {
107+
fmt.Printf("\n" + strings.Repeat("=", 60) + "\n")
108+
fmt.Printf("FAILED TESTS\n")
109+
fmt.Printf(strings.Repeat("=", 60) + "\n")
110+
for _, line := range failedTestLines {
111+
fmt.Printf("%s\n", line)
112+
}
113+
}
114+
104115
fmt.Printf("\n" + strings.Repeat("=", 60) + "\n")
105116
fmt.Printf("TOTAL SUMMARY\n")
106117
fmt.Printf(strings.Repeat("=", 60) + "\n")
@@ -152,3 +163,14 @@ func printResults(suite *runner.TestSuite, result runner.TestResult, verbosity r
152163

153164
fmt.Printf("\n")
154165
}
166+
167+
func collectFailedTestLines(suite *runner.TestSuite, result runner.TestResult) []string {
168+
lines := make([]string, 0, result.FailedTests)
169+
for i, tr := range result.TestResults {
170+
if tr.Passed {
171+
continue
172+
}
173+
lines = append(lines, fmt.Sprintf("%s %s (%s)", result.SuiteFileName, tr.TestID, suite.Tests[i].Description))
174+
}
175+
return lines
176+
}

0 commit comments

Comments
 (0)