diff --git a/go-junit-report_test.go b/go-junit-report_test.go index cb315c1..3aacf16 100644 --- a/go-junit-report_test.go +++ b/go-junit-report_test.go @@ -610,6 +610,38 @@ var testCases = []TestCase{ }, }, }, + { + name: "16-repeated-names.txt", + reportName: "16-report.xml", + report: &parser.Report{ + Packages: []parser.Package{ + { + Name: "package/repeated-names", + Time: 1, + Tests: []*parser.Test{ + { + Name: "TestRepeat", + Time: 0, + Result: parser.PASS, + Output: []string{}, + }, + { + Name: "TestRepeat", + Time: 0, + Result: parser.PASS, + Output: []string{}, + }, + { + Name: "TestRepeat", + Time: 0, + Result: parser.PASS, + Output: []string{}, + }, + }, + }, + }, + }, + }, } func TestParser(t *testing.T) { diff --git a/parser/parser.go b/parser/parser.go index b854861..bf3a123 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -198,7 +198,7 @@ func parseTime(time string) int { } func findTest(tests []*Test, name string) *Test { - for i := 0; i < len(tests); i++ { + for i := len(tests) - 1; i >= 0; i-- { if tests[i].Name == name { return tests[i] } diff --git a/tests/16-repeated-names.txt b/tests/16-repeated-names.txt new file mode 100644 index 0000000..b58f1ea --- /dev/null +++ b/tests/16-repeated-names.txt @@ -0,0 +1,8 @@ +=== RUN TestRepeat +--- PASS: TestRepeat (0.00s) +=== RUN TestRepeat +--- PASS: TestRepeat (0.00s) +=== RUN TestRepeat +--- PASS: TestRepeat (0.00s) +PASS +ok package/repeated-names 0.001s diff --git a/tests/16-report.xml b/tests/16-report.xml new file mode 100644 index 0000000..9bcc5d2 --- /dev/null +++ b/tests/16-report.xml @@ -0,0 +1,11 @@ + + + + + + + + + + +