@@ -21,9 +21,14 @@ type testSuiteXML struct {
2121}
2222
2323type 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"`
2732}
2833
2934type JunitXML struct {
@@ -34,24 +39,24 @@ func NewJunitXML() *JunitXML {
3439}
3540
3641func (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
3843
3944 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 ()
4348
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 ,
4951 ClassName : i .Pos .String (),
50- Status : strings .TrimSuffix (source , "; " ),
52+ Failure : failureXML {
53+ Message : i .Text ,
54+ Content : strings .Join (i .SourceLines , "\n " ),
55+ },
5156 }
5257
5358 testSuite .TestCases = append (testSuite .TestCases , tc )
54- suites [fromLinter ] = testSuite
59+ suites [suiteName ] = testSuite
5560 }
5661
5762 var res testSuitesXML
0 commit comments