Skip to content

Commit

Permalink
Add support to customize junit report config to omit spec labels (#1087)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankwilliams committed Dec 6, 2022
1 parent a3eed17 commit de44005
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion reporters/junit_report.go
Expand Up @@ -30,6 +30,9 @@ type JunitReportConfig struct {

//Enable OmitCapturedStdOutErr to prevent captured stdout/stderr appearing in system-out
OmitCapturedStdOutErr bool

// Enable OmitSpecLabels to prevent labels from appearing in the spec name
OmitSpecLabels bool
}

type JUnitTestSuites struct {
Expand Down Expand Up @@ -176,7 +179,7 @@ func GenerateJUnitReportWithConfig(report types.Report, dst string, config Junit
name = name + " " + spec.FullText()
}
labels := spec.Labels()
if len(labels) > 0 {
if len(labels) > 0 && !config.OmitSpecLabels {
name = name + " [" + strings.Join(labels, ", ") + "]"
}

Expand Down
3 changes: 2 additions & 1 deletion reporters/junit_report_test.go
Expand Up @@ -219,6 +219,7 @@ var _ = Describe("JunitReport", func() {
OmitTimelinesForSpecState: types.SpecStatePassed,
OmitFailureMessageAttr: true,
OmitCapturedStdOutErr: true,
OmitSpecLabels: true,
})).Should(Succeed())
DeferCleanup(os.Remove, fname)

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

failingSpec := suite.TestCases[0]
Ω(failingSpec.Name).Should(Equal("[It] A B C [dolphin, gorilla, cow, cat, dog]"))
Ω(failingSpec.Name).Should(Equal("[It] A B C"))
Ω(failingSpec.Classname).Should(Equal("My Suite"))
Ω(failingSpec.Status).Should(Equal("timedout"))
Ω(failingSpec.Skipped).Should(BeNil())
Expand Down

0 comments on commit de44005

Please sign in to comment.