Skip to content

Commit a4ffe52

Browse files
committed
Improve output of test summary
1 parent eff4dcd commit a4ffe52

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

h2spec.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,17 @@ func (tg *TestGroup) PrintFailedTestCase(level int) {
105105

106106
tg.PrintHeader(level)
107107

108+
numTestCaseFailed := 0
108109
for _, tc := range tg.testCases {
109110
if tc.verdict {
110111
continue
111112
}
112113
tc.PrintError(tc.expected, tc.actual, level+1)
114+
numTestCaseFailed += 1
115+
}
116+
117+
if numTestCaseFailed > 0 {
118+
fmt.Println("")
113119
}
114120

115121
for _, testGroup := range tg.testGroups {
@@ -614,14 +620,13 @@ func pair(name, value string) hpack.HeaderField {
614620

615621
// printSummary prints out the test summary of all tests performed.
616622
func printSummary(groups []*TestGroup, numTestCases, numSkipped, numFailed int) {
617-
fmt.Printf("\x1b[35m")
623+
fmt.Printf("\x1b[36m")
618624
fmt.Println(`
619-
*******************************************************************************
620-
* *
621-
* Test Summary *
622-
* *
623-
*******************************************************************************`)
624-
fmt.Println("\x1b[0m")
625+
===============================================================================
626+
Test Summary
627+
===============================================================================
628+
`)
629+
fmt.Printf("\x1b[0m")
625630
if numFailed > 0 {
626631
fmt.Println("Failed tests:")
627632
for _, tg := range groups {
@@ -631,12 +636,15 @@ func printSummary(groups []*TestGroup, numTestCases, numSkipped, numFailed int)
631636

632637
numPassed := numTestCases - numSkipped - numFailed
633638

634-
fmt.Printf("\n%v tests, %v passed, %v skipped, %v failed\n", numTestCases, numPassed, numSkipped, numFailed)
639+
fmt.Printf("\x1b[36m")
640+
fmt.Printf("%v tests, %v passed, %v skipped, %v failed\n", numTestCases, numPassed, numSkipped, numFailed)
641+
fmt.Printf("\x1b[0m")
635642
if numFailed == 0 {
636643
fmt.Printf("\x1b[32m")
637644
fmt.Printf("All tests passed\n")
638645
fmt.Printf("\x1b[0m")
639646
}
647+
fmt.Printf("\n")
640648
}
641649

642650
func Run(ctx *Context) {

0 commit comments

Comments
 (0)