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

Conversation

ryankwilliams
Copy link
Contributor

Change

Ginkgo tests that generate JUnit XML report may wish to omit labels from appearing within the spec. This is helpful when these results get imported into third party applications for analyzing/displaying test results. This commit adds a new field to the JunitReportConfig to be able to omit labels from being included within a spec. By default, labels will be included in the spec within the junit xml report (current behavior). Users can override this based on their needs.

Verification

package main

import (
	"testing"

	. "github.com/onsi/ginkgo/v2"
	"github.com/onsi/ginkgo/v2/reporters"
	. "github.com/onsi/gomega"
)

func TestPR(t *testing.T) {
	ReportAfterSuite("Test PR", func(report Report) {
		reporters.GenerateJUnitReportWithConfig(
			report,
			"test.xml",
			reporters.JunitReportConfig{OmitSpecLabels: true},
		)
	})

	RegisterFailHandler(Fail)
	RunSpecs(t, "Test PR", Label("pr-test"))
}

var _ = Describe("String comparison", func() {
	It("should be equal", Label("pr-test"), func() {
		Expect("apple").To(Equal("apple"))
	})
})
cat test.xml | grep testcase
          <testcase name="[It] String comparison should be equal" classname="Test PR" status="passed" time="0.0001772">
          </testcase>

Ginkgo tests that generate JUnit XML report may wish to omit
labels from appearing within the spec. This is helpful when these
results get imported into third party applications for
analyzing/displaying test results. This commit adds a new field to
the JunitReportConfig to be able to omit labels from being included
within a spec. By default, labels will be included in the spec within
the junit xml report (current behavior). Users can override this based
on their needs.
@onsi onsi merged commit de44005 into onsi:master Dec 6, 2022
@onsi
Copy link
Owner

onsi commented Dec 6, 2022

LGTM - thanks!

@ryankwilliams ryankwilliams deleted the junit-config-omit-spec-labels branch December 6, 2022 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants