...
1
16
17
18
19 package junit
20
21 import (
22 "encoding/xml"
23 "time"
24 )
25
26
27 type TestSuite struct {
28 XMLName xml.Name `xml:"testsuite"`
29
30 Name string `xml:"name,attr"`
31 Tests int `xml:"tests,attr"`
32 Disabled int `xml:"disabled,attr,omitempty"`
33 Errors int `xml:"errors,attr"`
34 Failures int `xml:"failures,attr"`
35 Skipped int `xml:"skipped,attr,omitempty"`
36 Time float64 `xml:"time,attr"`
37 Timestamp time.Time `xml:"timestamp,attr"`
38 ID int `xml:"id,attr,omitempty"`
39 Package string `xml:"package,attr,omitempty"`
40 Hostname string `xml:"hostname,attr"`
41
42 Properties []*Property `xml:"properties,omitempty"`
43 TestCases []*TestCase `xml:"testcase"`
44
45 SystemOut string `xml:"system-out,omitempty"`
46 SystemErr string `xml:"system-err,omitempty"`
47 }
48
49
50
51 func (t *TestSuite) Update() {
52 t.Tests = len(t.TestCases)
53 for _, tc := range t.TestCases {
54 t.Errors += len(tc.Errors)
55 t.Failures += len(tc.Failures)
56 if len(tc.Skipped) > 0 {
57 t.Skipped++
58 }
59 }
60 }
61
62
63 type Property struct {
64 XMLName xml.Name `xml:"property"`
65
66 Name string `xml:"name,attr"`
67 Value string `xml:"value,attr"`
68 }
69
70
71 type Error struct {
72 XMLName xml.Name `xml:"error"`
73
74 Message string `xml:"message,attr,omitempty"`
75 Type string `xml:"type,attr"`
76
77 Value string `xml:",cdata"`
78 }
79
80
81 type Failure struct {
82 XMLName xml.Name `xml:"failure"`
83
84 Message string `xml:"message,attr,omitempty"`
85 Type string `xml:"type,attr"`
86
87 Value string `xml:",cdata"`
88 }
89
90
91 type TestCase struct {
92 XMLName xml.Name `xml:"testcase"`
93
94 Name string `xml:"name,attr"`
95 Classname string `xml:"classname,attr"`
96 Status string `xml:"status,attr,omitempty"`
97 Assertions int `xml:"assertions,attr,omitempty"`
98 Time float64 `xml:"time,attr"`
99
100 Skipped string `xml:"skipped,omitempty"`
101
102 Errors []*Error `xml:"error,omitempty"`
103 Failures []*Failure `xml:"failure,omitempty"`
104 }
105
View as plain text