Skip to content

Commit

Permalink
[junit] Fix JUnit generated XML report.
Browse files Browse the repository at this point in the history
Based on the Maven surefire-plugin JUnit XSD schema [1], `name`
attribute in `testcase` is required. Let's use description value
that is currently used as `classname` attribute for this purpose.

This issue may lead to errors with JUnit plugin 1.32 for Jenkins.

[1] https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd
  • Loading branch information
jstourac committed Dec 20, 2022
1 parent af83a65 commit 72a6b9b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions reporter/junit_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type JUnitTestSuite struct {
type JUnitTestCase struct {
XMLName xml.Name `xml:"testcase"`
Package string `xml:"package,attr"`
ClassName string `xml:"classname,attr"`
Name string `xml:"name,attr"`
Time string `xml:"time,attr"`
Failure *JUnitFailure `xml:"failure"`
Skipped *JUnitSkipped `xml:"skipped"`
Expand Down Expand Up @@ -102,7 +102,7 @@ func convertJUnitReport(groups []*spec.TestGroup) []*JUnitTestSuite {

jtc := &JUnitTestCase{
Package: tg.ID(),
ClassName: tc.Desc,
Name: tc.Desc,
Time: fmt.Sprintf("%.04f", tc.Result.Duration.Seconds()),
}

Expand Down

0 comments on commit 72a6b9b

Please sign in to comment.