Skip to content

Commit eaed228

Browse files
authored
Print error text in <failure> tag content for more readable junit report (#2460)
1 parent 63f150e commit eaed228

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/printers/junitxml.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package printers
33
import (
44
"context"
55
"encoding/xml"
6+
"fmt"
67
"io"
78
"strings"
89

@@ -31,6 +32,7 @@ type testCaseXML struct {
3132

3233
type failureXML struct {
3334
Message string `xml:"message,attr"`
35+
Type string `xml:"type,attr"`
3436
Content string `xml:",cdata"`
3537
}
3638

@@ -57,8 +59,10 @@ func (p JunitXML) Print(ctx context.Context, issues []result.Issue) error {
5759
Name: i.FromLinter,
5860
ClassName: i.Pos.String(),
5961
Failure: failureXML{
60-
Message: i.Text,
61-
Content: strings.Join(i.SourceLines, "\n"),
62+
Type: i.Severity,
63+
Message: i.Pos.String() + ": " + i.Text,
64+
Content: fmt.Sprintf("%s: %s\nCategory: %s\nFile: %s\nLine: %d\nDetails: %s",
65+
i.Severity, i.Text, i.FromLinter, i.Pos.Filename, i.Pos.Line, strings.Join(i.SourceLines, "\n")),
6266
},
6367
}
6468

0 commit comments

Comments
 (0)