Skip to content

Commit de44005

Browse files
authoredDec 6, 2022
Add support to customize junit report config to omit spec labels (#1087)
1 parent a3eed17 commit de44005

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎reporters/junit_report.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ type JunitReportConfig struct {
3030

3131
//Enable OmitCapturedStdOutErr to prevent captured stdout/stderr appearing in system-out
3232
OmitCapturedStdOutErr bool
33+
34+
// Enable OmitSpecLabels to prevent labels from appearing in the spec name
35+
OmitSpecLabels bool
3336
}
3437

3538
type JUnitTestSuites struct {
@@ -176,7 +179,7 @@ func GenerateJUnitReportWithConfig(report types.Report, dst string, config Junit
176179
name = name + " " + spec.FullText()
177180
}
178181
labels := spec.Labels()
179-
if len(labels) > 0 {
182+
if len(labels) > 0 && !config.OmitSpecLabels {
180183
name = name + " [" + strings.Join(labels, ", ") + "]"
181184
}
182185

‎reporters/junit_report_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ var _ = Describe("JunitReport", func() {
219219
OmitTimelinesForSpecState: types.SpecStatePassed,
220220
OmitFailureMessageAttr: true,
221221
OmitCapturedStdOutErr: true,
222+
OmitSpecLabels: true,
222223
})).Should(Succeed())
223224
DeferCleanup(os.Remove, fname)
224225

@@ -251,7 +252,7 @@ var _ = Describe("JunitReport", func() {
251252
Ω(suite.TestCases).Should(HaveLen(4))
252253

253254
failingSpec := suite.TestCases[0]
254-
Ω(failingSpec.Name).Should(Equal("[It] A B C [dolphin, gorilla, cow, cat, dog]"))
255+
Ω(failingSpec.Name).Should(Equal("[It] A B C"))
255256
Ω(failingSpec.Classname).Should(Equal("My Suite"))
256257
Ω(failingSpec.Status).Should(Equal("timedout"))
257258
Ω(failingSpec.Skipped).Should(BeNil())

0 commit comments

Comments
 (0)
Please sign in to comment.