diff --git a/cmd/go2junit/output.go b/cmd/go2junit/output.go index 5fe3c62..6c6ec02 100644 --- a/cmd/go2junit/output.go +++ b/cmd/go2junit/output.go @@ -3,6 +3,7 @@ package main import ( "encoding/xml" "log" + "strings" "time" ) @@ -82,7 +83,7 @@ func (suite *Testsuite) getSuite(t time.Time, name string) *Testsuite { } } s := Testsuite{ - Name: name, + Name: suite.Name + "/" + name, Timestamp: t, } suite.Testsuites = append(suite.Testsuites, &s) @@ -90,10 +91,14 @@ func (suite *Testsuite) getSuite(t time.Time, name string) *Testsuite { } func (suite *Testsuite) getTest(t time.Time, testname string) *Testcase { - //path := strings.Split(testname, "/") - //for i := 0; i < len(path)-1; i++ { - // suite = suite.getSuite(t, path[i]) - //} + suitename := suite.Name + path := strings.Split(testname, "/") + for i := 0; i < len(path)-1; i++ { + suite = suite.getSuite(t, path[i]) + suitename = suitename + "/" + path[i] + } + testname = path[len(path)-1] + for _, test := range suite.Testcases { if test.Name == testname { return test @@ -104,7 +109,7 @@ func (suite *Testsuite) getTest(t time.Time, testname string) *Testcase { } test := Testcase{ Name: testname, - Classname: suite.Name, + Classname: suitename, } suite.Testcases = append(suite.Testcases, &test) return &test