From 3bf2bd5761d20496e3cbdb248a863b971af30421 Mon Sep 17 00:00:00 2001 From: Stanislav Fedii Date: Fri, 21 Feb 2020 14:49:08 -0500 Subject: [PATCH] Implemented a fix for test name and full name specification. --- result.go | 9 +++++++++ test.go | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/result.go b/result.go index 4d5fffa..bc7a4e3 100644 --- a/result.go +++ b/result.go @@ -78,6 +78,10 @@ func (r *result) addStep(step stepObject) { r.Steps = append(r.Steps, step) } +func (r *result) addFullName(FullName string) { + r.FullName = FullName +} + func (r *result) setStatus(status string) { r.Status = status } @@ -111,6 +115,11 @@ func (r *result) setDefaultLabels(t *testing.T) { r.addLabel("package", testPackage) r.addLabel("testClass", testPackage) r.addLabel("testMethod", t.Name()) + if len(wsd) == 0 { + r.addFullName(fmt.Sprintf("%s:%s", testFile, t.Name())) + } else { + r.addFullName(fmt.Sprintf("%s:%s", strings.TrimPrefix(testFile, wsd+"/"), t.Name())) + } if hostname, err := os.Hostname(); err == nil { r.addLabel("host", hostname) } diff --git a/test.go b/test.go index b66a6fa..abff33f 100644 --- a/test.go +++ b/test.go @@ -33,8 +33,7 @@ func Test(t *testing.T, testOptions ...Option) { r = newResult() r.UUID = generateUUID() r.Start = getTimestampMs() - r.Name = t.Name() - r.FullName = strings.Join(camelcase.Split(t.Name()), " ") + r.Name = strings.Join(camelcase.Split(t.Name())[1:], " ") r.Description = t.Name() r.setDefaultLabels(t) r.Steps = make([]stepObject, 0)