failures not counted correctly in some cases.
Summary output added.
This commit is contained in:
@@ -128,4 +128,33 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("\n\nSUMMARY\n\n")
|
||||
fmt.Printf("%-60s %-10s %-10s %-10s %-10s %-10s %-10s\n\n", "SUITE", "COUNT", "PASSED", "FAILURES", "ERRORS", "DISABLED", "SKIPPED")
|
||||
for _, suite := range testsuites.Suites {
|
||||
fmt.Printf("%-60s %-10d %-10d %-10d %-10d %-10d %-10d\n",
|
||||
suite.Name,
|
||||
suite.TestCount,
|
||||
suite.TestCount-suite.Failures-suite.Errors-suite.Skipped-suite.Disabled,
|
||||
suite.Failures, suite.Errors, suite.Disabled, suite.Skipped)
|
||||
}
|
||||
fmt.Printf("\n%-60s %-10d %-10d %-10d %-10d %-10d %-10d\n",
|
||||
"TOTAL",
|
||||
testsuites.Tests,
|
||||
testsuites.Tests-testsuites.Failures-testsuites.Errors-testsuites.Skipped-testsuites.Disabled,
|
||||
testsuites.Failures, testsuites.Errors, testsuites.Disabled, testsuites.Skipped)
|
||||
|
||||
if testsuites.Failures+testsuites.Errors+testsuites.Skipped+testsuites.Disabled > 0 {
|
||||
fmt.Printf("\nFAILED TESTS\n\n")
|
||||
printFailedTests("", "", testsuites.Suites)
|
||||
}
|
||||
}
|
||||
|
||||
func printFailedTests(indent string, parentTest string, tests []*Test) {
|
||||
for _, test := range tests {
|
||||
if test.Failures > 0 {
|
||||
testName := strings.TrimPrefix(test.Name, parentTest+"/")
|
||||
fmt.Printf("%s%s\n", indent, testName)
|
||||
printFailedTests(indent+" ", test.Name, test.Tests)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-8
@@ -39,8 +39,9 @@ type Test struct {
|
||||
Tests []*Test `xml:"testsuite,omitempty"`
|
||||
SystemOut string `xml:"system-out,omitempty"`
|
||||
|
||||
parent *Test
|
||||
t0 time.Time
|
||||
hasTests bool
|
||||
parent *Test
|
||||
t0 time.Time
|
||||
}
|
||||
|
||||
type Result struct {
|
||||
@@ -121,7 +122,8 @@ func (testsuites *Testsuites) Start(t time.Time, pkg string) {
|
||||
|
||||
func (testsuites *Testsuites) Test(t time.Time, pkg string, test string) {
|
||||
// This can be a test suite as well
|
||||
testsuites.getTest(t, pkg, test)
|
||||
testobj := testsuites.getTest(t, pkg, test)
|
||||
testobj.hasTests = true
|
||||
}
|
||||
|
||||
func (testsuites *Testsuites) Output(t time.Time, pkg string, test string, output string) {
|
||||
@@ -153,12 +155,14 @@ func (testsuites *Testsuites) Skip(t time.Time, pkg string, test string) {
|
||||
|
||||
func (suite *Test) Complete() {
|
||||
suite.TestCount = 0
|
||||
suite.Failures = 0
|
||||
suite.Errors = 0
|
||||
suite.Disabled = 0
|
||||
suite.Skipped = 0
|
||||
if len(suite.Tests) > 0 {
|
||||
suite.Failures = 0
|
||||
suite.Errors = 0
|
||||
suite.Disabled = 0
|
||||
suite.Skipped = 0
|
||||
}
|
||||
|
||||
if len(suite.Tests) == 0 {
|
||||
if len(suite.Tests) == 0 && suite.hasTests {
|
||||
suite.TestCount = 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user