From 29213b609b3284f91a12226d3e4fd6f429152c13 Mon Sep 17 00:00:00 2001 From: Marcus Deglos Date: Sat, 6 Sep 2025 13:13:40 +0100 Subject: [PATCH 1/6] Fix #962 - use the title for the jUnit test case name --- outputs/junit.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/outputs/junit.go b/outputs/junit.go index d50e3677e..df33685bb 100644 --- a/outputs/junit.go +++ b/outputs/junit.go @@ -47,11 +47,16 @@ func (r JUnit) Output(w io.Writer, results <-chan []resource.TestResult, endTime = testResult.EndTime } duration := strconv.FormatFloat(testResult.Duration.Seconds(), 'f', 3, 64) - summary[testCount] = "\n" + testcaseName := fmt.Sprintf("%s %s %s", + testResult.ResourceType, + escapeString(testResult.ResourceId), + testResult.Property); + if (testResult.Title != "") { + testcaseName = testResult.Title; + } + summary[testCount] = "\n" if testResult.Result == resource.FAIL { summary[testCount] += "" + escapeString(humanizeResult(testResult, true, includeRaw)) + From 20333ca3e6c61762a3e736175d2960971c5c782e Mon Sep 17 00:00:00 2001 From: Marcus Deglos Date: Sat, 6 Sep 2025 13:18:30 +0100 Subject: [PATCH 2/6] Escape the test-case title provided in the config. --- outputs/junit.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/outputs/junit.go b/outputs/junit.go index df33685bb..6c19def61 100644 --- a/outputs/junit.go +++ b/outputs/junit.go @@ -52,7 +52,7 @@ func (r JUnit) Output(w io.Writer, results <-chan []resource.TestResult, escapeString(testResult.ResourceId), testResult.Property); if (testResult.Title != "") { - testcaseName = testResult.Title; + testcaseName = escapeString(testResult.Title); } summary[testCount] = " Date: Sat, 6 Sep 2025 13:22:17 +0100 Subject: [PATCH 3/6] Refactor to use Sprintf for readabilitly. --- outputs/junit.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/outputs/junit.go b/outputs/junit.go index 6c19def61..2c36fcf26 100644 --- a/outputs/junit.go +++ b/outputs/junit.go @@ -54,9 +54,11 @@ func (r JUnit) Output(w io.Writer, results <-chan []resource.TestResult, if (testResult.Title != "") { testcaseName = escapeString(testResult.Title); } - summary[testCount] = "\n" + summary[testCount] = fmt.Sprintf("\n", + testcaseName, + duration, + ); + if testResult.Result == resource.FAIL { summary[testCount] += "" + escapeString(humanizeResult(testResult, true, includeRaw)) + From 3100e6500c99a0517f8125094a28a3ea92188109 Mon Sep 17 00:00:00 2001 From: Keith Gaughan Date: Sun, 9 Aug 2026 13:00:51 +0100 Subject: [PATCH 4/6] Escape things once Co-authored-by: Keith Gaughan --- outputs/junit.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/outputs/junit.go b/outputs/junit.go index 2c36fcf26..c42233ce2 100644 --- a/outputs/junit.go +++ b/outputs/junit.go @@ -49,13 +49,13 @@ func (r JUnit) Output(w io.Writer, results <-chan []resource.TestResult, duration := strconv.FormatFloat(testResult.Duration.Seconds(), 'f', 3, 64) testcaseName := fmt.Sprintf("%s %s %s", testResult.ResourceType, - escapeString(testResult.ResourceId), + testResult.ResourceId, testResult.Property); if (testResult.Title != "") { - testcaseName = escapeString(testResult.Title); + testcaseName = testResult.Title } summary[testCount] = fmt.Sprintf("\n", - testcaseName, + escapeString(testcaseName), duration, ); From 9108962d04e0d4891572634e991e202f251f0463 Mon Sep 17 00:00:00 2001 From: Keith Gaughan Date: Sun, 9 Aug 2026 13:04:37 +0100 Subject: [PATCH 5/6] Fix the indentation --- outputs/junit.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/outputs/junit.go b/outputs/junit.go index c42233ce2..0ed6cddf5 100644 --- a/outputs/junit.go +++ b/outputs/junit.go @@ -47,17 +47,20 @@ func (r JUnit) Output(w io.Writer, results <-chan []resource.TestResult, endTime = testResult.EndTime } duration := strconv.FormatFloat(testResult.Duration.Seconds(), 'f', 3, 64) - testcaseName := fmt.Sprintf("%s %s %s", - testResult.ResourceType, - testResult.ResourceId, - testResult.Property); - if (testResult.Title != "") { - testcaseName = testResult.Title - } - summary[testCount] = fmt.Sprintf("\n", - escapeString(testcaseName), - duration, - ); + testcaseName := fmt.Sprintf( + "%s %s %s", + testResult.ResourceType, + testResult.ResourceId, + testResult.Property, + ) + if (testResult.Title != "") { + testcaseName = testResult.Title + } + summary[testCount] = fmt.Sprintf( + "\n", + escapeString(testcaseName), + duration, + ) if testResult.Result == resource.FAIL { summary[testCount] += "" + From 2652f5f8d0b61d39b96eaebcc4c394f367aea9e2 Mon Sep 17 00:00:00 2001 From: Keith Gaughan Date: Sun, 9 Aug 2026 13:09:03 +0100 Subject: [PATCH 6/6] Lazily build the fallout title string --- outputs/junit.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/outputs/junit.go b/outputs/junit.go index 0ed6cddf5..86ab2fbb2 100644 --- a/outputs/junit.go +++ b/outputs/junit.go @@ -47,14 +47,14 @@ func (r JUnit) Output(w io.Writer, results <-chan []resource.TestResult, endTime = testResult.EndTime } duration := strconv.FormatFloat(testResult.Duration.Seconds(), 'f', 3, 64) - testcaseName := fmt.Sprintf( - "%s %s %s", - testResult.ResourceType, - testResult.ResourceId, - testResult.Property, - ) - if (testResult.Title != "") { - testcaseName = testResult.Title + testcaseName := testResult.Title + if testcaseName == "" { + testcaseName = fmt.Sprintf( + "%s %s %s", + testResult.ResourceType, + testResult.ResourceId, + testResult.Property, + ) } summary[testCount] = fmt.Sprintf( "\n",