From f2384c9d239b95a1b9d0b5e4171f1ff2b0a78508 Mon Sep 17 00:00:00 2001 From: Donal Byrne Date: Tue, 4 Jan 2022 11:11:20 +0100 Subject: [PATCH 1/3] Print error text in tag content for more readable junit reports --- pkg/printers/junitxml.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/printers/junitxml.go b/pkg/printers/junitxml.go index 7a68821eff6b..2b03270e10d0 100644 --- a/pkg/printers/junitxml.go +++ b/pkg/printers/junitxml.go @@ -58,7 +58,7 @@ func (p JunitXML) Print(ctx context.Context, issues []result.Issue) error { ClassName: i.Pos.String(), Failure: failureXML{ Message: i.Text, - Content: strings.Join(i.SourceLines, "\n"), + Content: i.Text + ":\n" + strings.Join(i.SourceLines, "\n"), }, } From 9eef164d9cdaec0456f24b1e268fe61520bafe27 Mon Sep 17 00:00:00 2001 From: Donal Byrne Date: Tue, 4 Jan 2022 11:43:39 +0100 Subject: [PATCH 2/3] Added file and line to both message and content of junit tag --- pkg/printers/junitxml.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/printers/junitxml.go b/pkg/printers/junitxml.go index 2b03270e10d0..dc22ddfc4ffc 100644 --- a/pkg/printers/junitxml.go +++ b/pkg/printers/junitxml.go @@ -57,8 +57,8 @@ func (p JunitXML) Print(ctx context.Context, issues []result.Issue) error { Name: i.FromLinter, ClassName: i.Pos.String(), Failure: failureXML{ - Message: i.Text, - Content: i.Text + ":\n" + strings.Join(i.SourceLines, "\n"), + Message: i.Pos.String() + ": " + i.Text, + Content: i.Pos.String() + ": " + i.Text + "\n" + strings.Join(i.SourceLines, "\n"), }, } From 62fe2c9239719055592f228fccad675371403c97 Mon Sep 17 00:00:00 2001 From: Donal Byrne Date: Wed, 5 Jan 2022 08:11:58 +0100 Subject: [PATCH 3/3] Added to junit failureXml, print content according to 'https://www.ibm.com/docs/en/developer-for-zos/14.1.0?topic=formats-junit-xml-format' --- pkg/printers/junitxml.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/printers/junitxml.go b/pkg/printers/junitxml.go index dc22ddfc4ffc..fd3aecac7518 100644 --- a/pkg/printers/junitxml.go +++ b/pkg/printers/junitxml.go @@ -3,6 +3,7 @@ package printers import ( "context" "encoding/xml" + "fmt" "io" "strings" @@ -31,6 +32,7 @@ type testCaseXML struct { type failureXML struct { Message string `xml:"message,attr"` + Type string `xml:"type,attr"` Content string `xml:",cdata"` } @@ -57,8 +59,10 @@ func (p JunitXML) Print(ctx context.Context, issues []result.Issue) error { Name: i.FromLinter, ClassName: i.Pos.String(), Failure: failureXML{ + Type: i.Severity, Message: i.Pos.String() + ": " + i.Text, - Content: i.Pos.String() + ": " + i.Text + "\n" + strings.Join(i.SourceLines, "\n"), + 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")), }, }