Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to customize junit report config to omit spec labels #1087

Merged
merged 1 commit into from Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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