File tree Expand file tree Collapse file tree 9 files changed +77
-2
lines changed Expand file tree Collapse file tree 9 files changed +77
-2
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,6 @@ vendor/
19
19
# Intellij IDEA folder
20
20
.idea /
21
21
/maven_reference_project /
22
+
23
+ # Mac OS
24
+ .DS_Store
Original file line number Diff line number Diff line change
1
+ package example
2
+
3
+ import (
4
+ "github.com/dailymotion/allure-go"
5
+ "testing"
6
+ )
7
+
8
+ func TestAllureWithLinks (t * testing.T ) {
9
+ allure .Test (t , allure .Description ("Test with links" ),
10
+ allure .Link ("https://github.com/" , "GitHub Link" ),
11
+ allure .Issue ("https://github.com/" , "GitHub Issue" ),
12
+ allure .TestCase ("https://github.com/" , "GitHub TestCase" ),
13
+ allure .Action (func () {}))
14
+ }
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ func TestAllureWithLabels(t *testing.T) {
92
92
allure .Story ("story2" ),
93
93
allure .Feature ("feature1" ),
94
94
allure .Feature ("feature2" ),
95
+ allure .Layer ("integration-tests" ),
95
96
allure .Tag ("tag1" ),
96
97
allure .Tags ("tag2" , "tag3" ),
97
98
allure .Label ("customLabel1" , "customLabel1Value" ),
Original file line number Diff line number Diff line change 1
1
package allure
2
2
3
3
type hasOptions interface {
4
+ addLink (url , name string , linkType LinkType )
4
5
addLabel (key string , value string )
5
6
addDescription (description string )
6
7
addParameter (name string , value interface {})
Original file line number Diff line number Diff line change
1
+ package allure
2
+
3
+ type LinkType string
4
+
5
+ const (
6
+ IssueType LinkType = "issue"
7
+ AnyLinkType LinkType = "link"
8
+ TestCaseType LinkType = "test_case"
9
+ )
10
+
11
+ type link struct {
12
+ Url string `json:"url,omitempty"`
13
+ Name string `json:"name,omitempty"`
14
+ Type LinkType `json:"type,omitempty"`
15
+ }
Original file line number Diff line number Diff line change @@ -98,6 +98,30 @@ func Name(name string) Option {
98
98
}
99
99
}
100
100
101
+ func Layer (layer string ) Option {
102
+ return func (r hasOptions ) {
103
+ r .addLabel ("layer" , layer )
104
+ }
105
+ }
106
+
107
+ func Link (url , name string ) Option {
108
+ return func (r hasOptions ) {
109
+ r .addLink (url , name , AnyLinkType )
110
+ }
111
+ }
112
+
113
+ func Issue (url , name string ) Option {
114
+ return func (r hasOptions ) {
115
+ r .addLink (url , name , IssueType )
116
+ }
117
+ }
118
+
119
+ func TestCase (url , name string ) Option {
120
+ return func (r hasOptions ) {
121
+ r .addLink (url , name , TestCaseType )
122
+ }
123
+ }
124
+
101
125
func Suite (suite string ) Option {
102
126
return func (r hasOptions ) {
103
127
r .addLabel ("suite" , suite )
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import (
12
12
"github.com/pkg/errors"
13
13
)
14
14
15
- //result is the top level report object for a test
15
+ // result is the top level report object for a test
16
16
type result struct {
17
17
UUID string `json:"uuid,omitempty"`
18
18
TestCaseID string `json:"testCaseId,omitempty"`
@@ -30,6 +30,7 @@ type result struct {
30
30
Children []string `json:"children,omitempty"`
31
31
FullName string `json:"fullName,omitempty"`
32
32
Labels []label `json:"labels,omitempty"`
33
+ Links []link `json:"links,omitempty"`
33
34
Test func () `json:"-"`
34
35
}
35
36
@@ -135,6 +136,14 @@ func (r *result) setDefaultLabels(t *testing.T) {
135
136
// Framework string
136
137
}
137
138
139
+ func (r * result ) addLink (url , name string , linkType LinkType ) {
140
+ r .Links = append (r .Links , link {
141
+ Url : url ,
142
+ Name : name ,
143
+ Type : linkType ,
144
+ })
145
+ }
146
+
138
147
func (r * result ) addLabel (name string , value string ) {
139
148
r .Labels = append (r .Labels , label {
140
149
Name : name ,
Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ func (s *stepObject) addReason(reason string) {
30
30
s .StatusDetails .Message = reason
31
31
}
32
32
33
+ func (s * stepObject ) addLink (url , name string , linkType LinkType ) {
34
+ // Step doesn't have links
35
+ }
36
+
33
37
func (s * stepObject ) addLabel (key string , value string ) {
34
38
// Step doesn't have labels
35
39
}
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ type container struct {
26
26
Stop int64 `json:"stop"`
27
27
}
28
28
29
- //subContainer defines a step
29
+ // subContainer defines a step
30
30
type subContainer struct {
31
31
Name string `json:"name,omitempty"`
32
32
Status string `json:"status,omitempty"`
@@ -41,6 +41,10 @@ type subContainer struct {
41
41
Action func () `json:"-"`
42
42
}
43
43
44
+ func (s * subContainer ) addLink (url , name string , linkType LinkType ) {
45
+ panic ("implement me" )
46
+ }
47
+
44
48
func (sc * subContainer ) addLabel (key string , value string ) {
45
49
panic ("implement me" )
46
50
}
You can’t perform that action at this time.
0 commit comments