From bfbf24a6c4133b5c8b31113a81f06f5520de4b88 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Wed, 20 Nov 2024 23:35:05 +0100 Subject: [PATCH] reintroducing nesting. --- cmd/go2junit/output.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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