@@ -21,9 +21,14 @@ type testSuiteXML struct {
21
21
}
22
22
23
23
type testCaseXML struct {
24
- Name string `xml:"name,attr"`
25
- ClassName string `xml:"classname,attr"`
26
- Status string `xml:"status,attr"`
24
+ Name string `xml:"name,attr"`
25
+ ClassName string `xml:"classname,attr"`
26
+ Failure failureXML `xml:"failure"`
27
+ }
28
+
29
+ type failureXML struct {
30
+ Message string `xml:"message,attr"`
31
+ Content string `xml:",cdata"`
27
32
}
28
33
29
34
type JunitXML struct {
@@ -34,24 +39,24 @@ func NewJunitXML() *JunitXML {
34
39
}
35
40
36
41
func (JunitXML ) Print (ctx context.Context , issues <- chan result.Issue ) error {
37
- suites := make (map [string ]testSuiteXML ) // use a map to group- by "FromLinter"
42
+ suites := make (map [string ]testSuiteXML ) // use a map to group by file
38
43
39
44
for i := range issues {
40
- fromLinter := i .FromLinter
41
- testSuite := suites [fromLinter ]
42
- testSuite .Suite = fromLinter
45
+ suiteName := i .FilePath ()
46
+ testSuite := suites [suiteName ]
47
+ testSuite .Suite = i . FilePath ()
43
48
44
- var source string
45
- for _ , line := range i .SourceLines {
46
- source += strings .TrimSpace (line ) + "; "
47
- }
48
- tc := testCaseXML {Name : i .Text ,
49
+ tc := testCaseXML {
50
+ Name : i .FromLinter ,
49
51
ClassName : i .Pos .String (),
50
- Status : strings .TrimSuffix (source , "; " ),
52
+ Failure : failureXML {
53
+ Message : i .Text ,
54
+ Content : strings .Join (i .SourceLines , "\n " ),
55
+ },
51
56
}
52
57
53
58
testSuite .TestCases = append (testSuite .TestCases , tc )
54
- suites [fromLinter ] = testSuite
59
+ suites [suiteName ] = testSuite
55
60
}
56
61
57
62
var res testSuitesXML
0 commit comments