From 043af1a6d38babb12e65a1270878e1b46976eb4c Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Tue, 9 Jul 2024 13:09:24 -0700 Subject: [PATCH 1/2] add skipped attribute to junit xml testsuite --- internal/junitxml/report.go | 2 ++ .../testdata/junitxml-report-skip-empty.golden | 8 ++++---- internal/junitxml/testdata/junitxml-report.golden | 10 +++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/internal/junitxml/report.go b/internal/junitxml/report.go index 9857f6ba..9b7cb679 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"` 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 == "" { diff --git a/internal/junitxml/testdata/junitxml-report-skip-empty.golden b/internal/junitxml/testdata/junitxml-report-skip-empty.golden index 432accd4..6f66f7b5 100644 --- a/internal/junitxml/testdata/junitxml-report-skip-empty.golden +++ b/internal/junitxml/testdata/junitxml-report-skip-empty.golden @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ sometimes main can exit 2 FAIL gotest.tools/gotestsum/testjson/internal/badmain 0.001s - + @@ -35,7 +35,7 @@ - + @@ -68,7 +68,7 @@ - + diff --git a/internal/junitxml/testdata/junitxml-report.golden b/internal/junitxml/testdata/junitxml-report.golden index 9988d8b0..d509ce61 100644 --- a/internal/junitxml/testdata/junitxml-report.golden +++ b/internal/junitxml/testdata/junitxml-report.golden @@ -1,6 +1,6 @@ - + @@ -8,12 +8,12 @@ sometimes main can exit 2 FAIL gotest.tools/gotestsum/testjson/internal/badmain 0.001s - + - + @@ -40,7 +40,7 @@ - + @@ -73,7 +73,7 @@ - + From 875f3cd5ca331630dbd2b216e190a27bda5a1c1b Mon Sep 17 00:00:00 2001 From: Bryce Kahle Date: Tue, 9 Jul 2024 13:23:23 -0700 Subject: [PATCH 2/2] omit empty skipped --- internal/junitxml/report.go | 2 +- .../junitxml/testdata/junitxml-report-skip-empty.golden | 4 ++-- internal/junitxml/testdata/junitxml-report.golden | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/junitxml/report.go b/internal/junitxml/report.go index 9b7cb679..d72340fc 100644 --- a/internal/junitxml/report.go +++ b/internal/junitxml/report.go @@ -33,7 +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"` + Skipped int `xml:"skipped,attr,omitempty"` Time string `xml:"time,attr"` Name string `xml:"name,attr"` Properties []JUnitProperty `xml:"properties>property,omitempty"` diff --git a/internal/junitxml/testdata/junitxml-report-skip-empty.golden b/internal/junitxml/testdata/junitxml-report-skip-empty.golden index 6f66f7b5..9c134b4e 100644 --- a/internal/junitxml/testdata/junitxml-report-skip-empty.golden +++ b/internal/junitxml/testdata/junitxml-report-skip-empty.golden @@ -1,6 +1,6 @@ - + @@ -35,7 +35,7 @@ - + diff --git a/internal/junitxml/testdata/junitxml-report.golden b/internal/junitxml/testdata/junitxml-report.golden index d509ce61..d4ce2057 100644 --- a/internal/junitxml/testdata/junitxml-report.golden +++ b/internal/junitxml/testdata/junitxml-report.golden @@ -1,6 +1,6 @@ - + @@ -8,7 +8,7 @@ sometimes main can exit 2 FAIL gotest.tools/gotestsum/testjson/internal/badmain 0.001s - + @@ -40,7 +40,7 @@ - +