Repository: gotestyourself/gotestsum
Pull request #422 (2024-07-09 20:09:34)

add skipped attribute to junit xml testsuite


Patch:
diff --git a/internal/junitxml/report.go b/internal/junitxml/report.go
index 9857f6b..d72340f 100644
--- a/internal/junitxml/report.go
+++ b/internal/junitxml/report.go
@@ -33,6 +33,7 @@ type JUnitTestSuite struct {
 	XMLName    xml.Name        `xml:"testsuite"`
 	Tests      int             `xml:"tests,attr"`
 	Failures   int             `xml:"failures,attr"`
+	Skipped    int             `xml:"skipped,attr,omitempty"`
 	Time       string          `xml:"time,attr"`
 	Name       string          `xml:"name,attr"`
 	Properties []JUnitProperty `xml:"properties>property,omitempty"`
@@ -116,6 +117,7 @@ func generate(exec *testjson.Execution, cfg Config) JUnitTestSuites {
 			Properties: packageProperties(version),
 			TestCases:  packageTestCases(pkg, cfg.FormatTestCaseClassname),
 			Failures:   len(pkg.Failed),
+			Skipped:    len(pkg.Skipped),
 			Timestamp:  cfg.customTimestamp,
 		}
 		if cfg.customTimestamp == "" {


Test patch:
diff --git a/internal/junitxml/testdata/junitxml-report-skip-empty.golden b/internal/junitxml/testdata/junitxml-report-skip-empty.golden
index 432accd..9c134b4 100644
--- a/internal/junitxml/testdata/junitxml-report-skip-empty.golden
+++ b/internal/junitxml/testdata/junitxml-report-skip-empty.golden
@@ -8,7 +8,7 @@
 			<failure message="Failed" type="">sometimes main can exit 2&#xA;FAIL&#x9;gotest.tools/gotestsum/testjson/internal/badmain&#x9;0.001s&#xA;</failure>
 		</testcase>
 	</testsuite>
-	<testsuite tests="18" failures="0" time="0.000000" name="gotest.tools/gotestsum/testjson/internal/good" timestamp="0001-01-01T00:00:00Z">
+	<testsuite tests="18" failures="0" skipped="2" time="0.000000" name="gotest.tools/gotestsum/testjson/internal/good" timestamp="0001-01-01T00:00:00Z">
 		<properties>
 			<property name="go.version" value="go7.7.7"></property>
 		</properties>
@@ -68,7 +68,7 @@
 		<testcase classname="gotest.tools/gotestsum/testjson/internal/parallelfails" name="TestPassedWithStdout" time="0.000000"></testcase>
 		<testcase classname="gotest.tools/gotestsum/testjson/internal/parallelfails" name="TestWithStderr" time="0.000000"></testcase>
 	</testsuite>
-	<testsuite tests="29" failures="4" time="0.020000" name="gotest.tools/gotestsum/testjson/internal/withfails" timestamp="0001-01-01T00:00:00Z">
+	<testsuite tests="29" failures="4" skipped="3" time="0.020000" name="gotest.tools/gotestsum/testjson/internal/withfails" timestamp="0001-01-01T00:00:00Z">
 		<properties>
 			<property name="go.version" value="go7.7.7"></property>
 		</properties>
diff --git a/internal/junitxml/testdata/junitxml-report.golden b/internal/junitxml/testdata/junitxml-report.golden
index 9988d8b..d4ce205 100644
--- a/internal/junitxml/testdata/junitxml-report.golden
+++ b/internal/junitxml/testdata/junitxml-report.golden
@@ -13,7 +13,7 @@
 			<property name="go.version" value="go7.7.7"></property>
 		</properties>
 	</testsuite>
-	<testsuite tests="18" failures="0" time="0.000000" name="gotest.tools/gotestsum/testjson/internal/good" timestamp="0001-01-01T00:00:00Z">
+	<testsuite tests="18" failures="0" skipped="2" time="0.000000" name="gotest.tools/gotestsum/testjson/internal/good" timestamp="0001-01-01T00:00:00Z">
 		<properties>
 			<property name="go.version" value="go7.7.7"></property>
 		</properties>
@@ -73,7 +73,7 @@
 		<testcase classname="gotest.tools/gotestsum/testjson/internal/parallelfails" name="TestPassedWithStdout" time="0.000000"></testcase>
 		<testcase classname="gotest.tools/gotestsum/testjson/internal/parallelfails" name="TestWithStderr" time="0.000000"></testcase>
 	</testsuite>
-	<testsuite tests="29" failures="4" time="0.020000" name="gotest.tools/gotestsum/testjson/internal/withfails" timestamp="0001-01-01T00:00:00Z">
+	<testsuite tests="29" failures="4" skipped="3" time="0.020000" name="gotest.tools/gotestsum/testjson/internal/withfails" timestamp="0001-01-01T00:00:00Z">
 		<properties>
 			<property name="go.version" value="go7.7.7"></property>
 		</properties>