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

Focus not running tests when using full name #1277

Closed
tumberino opened this issue Sep 26, 2023 · 2 comments
Closed

Focus not running tests when using full name #1277

tumberino opened this issue Sep 26, 2023 · 2 comments

Comments

@tumberino
Copy link

Minimal example

package ginkgo_test

import (
	"testing"

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

func TestExamples(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Example Suite")
}

var _ = Describe("Example", func() {
	It("example pass", func() {
		Expect("A").To(Equal("A"))
	})
})

If I run ginkgo normally, the test runs and passes. Using ginkgo --junit-report=junit.xml to produce junit report I see the name of the test has been generated.

<testcase name="[It] Example example pass" classname="Example Suite" status="passed" time="4.6184e-05">

If I use the full testcase name as the argument for -focus e.g. ginkgo -focus "[It] Example example pass" the test gets skipped.

Will run 0 of 1 specs
S

Ran 0 of 1 Specs in 0.000 seconds
SUCCESS! -- 0 Passed | 0 Failed | 0 Pending | 1 Skipped

If I escape the [ and ] e.g. ginkgo -focus "\[It\] Example example pass". It still skips.

Will run 0 of 1 specs
S

Ran 0 of 1 Specs in 0.000 seconds
SUCCESS! -- 0 Passed | 0 Failed | 0 Pending | 1 Skipped

Only when I remove the [It] prefix does it select the correct test, ginkgo -focus "Example example pass"

Will run 1 of 1 specs
•

Ran 1 of 1 Specs in 0.000 seconds
SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped
PASS

Is there a better way to select the tests?

For background, trying to select the failed tests from the report and rerun them but selecting by test case name doesn't appear to work, as above.

@onsi
Copy link
Owner

onsi commented Sep 26, 2023

hey there,

yes you'll need to strip the [It] from the test name. The full test name is just the concatenation of the container strings and the It string however for historical reasons that don't make too much sense any more, the JUnit report adds [It], however I'd rather not change that as it might break users who have come to rely on it/expect it.

This section of the docs lists all the ways you can filter specs.

@tumberino
Copy link
Author

thanks I will see what can be done elsewhere

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

No branches or pull requests

2 participants