Print error text in <failure> tag content for more readable junit report (#2460)
This commit is contained in:
parent
63f150ead1
commit
eaed228d2f
@ -3,6 +3,7 @@ package printers
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -31,6 +32,7 @@ type testCaseXML struct {
|
|||||||
|
|
||||||
type failureXML struct {
|
type failureXML struct {
|
||||||
Message string `xml:"message,attr"`
|
Message string `xml:"message,attr"`
|
||||||
|
Type string `xml:"type,attr"`
|
||||||
Content string `xml:",cdata"`
|
Content string `xml:",cdata"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +59,10 @@ func (p JunitXML) Print(ctx context.Context, issues []result.Issue) error {
|
|||||||
Name: i.FromLinter,
|
Name: i.FromLinter,
|
||||||
ClassName: i.Pos.String(),
|
ClassName: i.Pos.String(),
|
||||||
Failure: failureXML{
|
Failure: failureXML{
|
||||||
Message: i.Text,
|
Type: i.Severity,
|
||||||
Content: strings.Join(i.SourceLines, "\n"),
|
Message: i.Pos.String() + ": " + i.Text,
|
||||||
|
Content: fmt.Sprintf("%s: %s\nCategory: %s\nFile: %s\nLine: %d\nDetails: %s",
|
||||||
|
i.Severity, i.Text, i.FromLinter, i.Pos.Filename, i.Pos.Line, strings.Join(i.SourceLines, "\n")),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user