@@ -3,43 +3,106 @@ package junit
3
3
import (
4
4
"encoding/xml"
5
5
"testing"
6
+ "time"
6
7
7
8
"github.com/jstemmer/go-junit-report/v2/gtr"
8
9
9
10
"github.com/google/go-cmp/cmp"
10
11
)
11
12
12
13
func TestCreateFromReport (t * testing.T ) {
13
- // TODO: complete this report
14
14
report := gtr.Report {
15
15
Packages : []gtr.Package {
16
16
{
17
+ Name : "package/name" ,
18
+ Timestamp : time .Date (2022 , 6 , 26 , 0 , 0 , 0 , 0 , time .UTC ),
19
+ Duration : 1 * time .Second ,
20
+ Coverage : 0.9 ,
21
+ Output : []string {"output" },
22
+ Properties : map [string ]string {"go.version" : "go1.18" },
17
23
Tests : []gtr.Test {
24
+ {
25
+ Name : "TestPass" ,
26
+ Result : gtr .Pass ,
27
+ Output : []string {"ok" },
28
+ },
18
29
{
19
30
Name : "TestFail" ,
20
31
Result : gtr .Fail ,
32
+ Output : []string {"fail" },
33
+ },
34
+ {
35
+ Name : "TestSkip" ,
36
+ Result : gtr .Skip ,
37
+ },
38
+ {
39
+ Name : "TestIncomplete" ,
40
+ Result : gtr .Unknown ,
21
41
},
22
42
},
43
+ BuildError : gtr.Error {Name : "Build error" },
44
+ RunError : gtr.Error {Name : "Run error" },
23
45
},
24
46
},
25
47
}
26
48
27
49
want := Testsuites {
28
- Tests : 1 ,
50
+ Tests : 6 ,
51
+ Errors : 3 ,
29
52
Failures : 1 ,
53
+ Skipped : 1 ,
30
54
Suites : []Testsuite {
31
55
{
32
- Tests : 1 ,
33
- Failures : 1 ,
34
- Time : "0.000" ,
35
- ID : 0 ,
56
+ Name : "package/name" ,
57
+ Tests : 6 ,
58
+ Errors : 3 ,
59
+ ID : 0 ,
60
+ Failures : 1 ,
61
+ Skipped : 1 ,
62
+ Time : "1.000" ,
63
+ Timestamp : "2022-06-26T00:00:00Z" ,
64
+ Properties : & []Property {
65
+ {Name : "go.version" , Value : "go1.18" },
66
+ {Name : "coverage.statements.pct" , Value : "0.90" },
67
+ },
36
68
Testcases : []Testcase {
37
69
{
38
- Name : "TestFail" ,
39
- Time : "0.000" ,
40
- Failure : & Result {Message : "Failed" },
70
+ Name : "TestPass" ,
71
+ Classname : "package/name" ,
72
+ Time : "0.000" ,
73
+ SystemOut : & Output {Data : "ok" },
74
+ },
75
+ {
76
+ Name : "TestFail" ,
77
+ Classname : "package/name" ,
78
+ Time : "0.000" ,
79
+ Failure : & Result {Message : "Failed" , Data : "fail" },
80
+ },
81
+ {
82
+ Name : "TestSkip" ,
83
+ Classname : "package/name" ,
84
+ Time : "0.000" ,
85
+ Skipped : & Result {Message : "Skipped" },
86
+ },
87
+ {
88
+ Name : "TestIncomplete" ,
89
+ Classname : "package/name" ,
90
+ Time : "0.000" ,
91
+ Error : & Result {Message : "No test result found" },
92
+ },
93
+ {
94
+ Classname : "Build error" ,
95
+ Time : "0.000" ,
96
+ Error : & Result {Message : "Build error" },
97
+ },
98
+ {
99
+ Name : "Failure" ,
100
+ Classname : "Run error" ,
101
+ Time : "0.000" ,
102
+ Error : & Result {Message : "Runtime error" },
41
103
},
42
104
},
105
+ SystemOut : & Output {Data : "output" },
43
106
},
44
107
},
45
108
}
0 commit comments