Skip to content

Commit

Permalink
Merge pull request #25 from dailymotion/test_name_fix
Browse files Browse the repository at this point in the history
Implemented a fix for test name and full name specification.
  • Loading branch information
ubermensch01 committed Feb 27, 2020
2 parents 9994694 + 3bf2bd5 commit 656b250
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 9 additions & 0 deletions result.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 656b250

Please sign in to comment.