Closed johnnycxm closed 1 year ago
hey there - first I'd encourage you to put all the test fils in the test package by giving them a name that ends in _test.go
- what you're doing works but it can get a bit confusing.
As for flags - please follow the pattern established here:
https://onsi.github.io/ginkgo/#supporting-custom-configuration-custom-command-line-flags
I don't generally use TestMain
and the pattern outlined above is the tested and supported pattern for passing custom flags into a Ginkgo suite.
Thanks for your reply. I'v tied this pattern, put all custom command line flags parsing into a init() func, I changed e2e_test.go to this:
package test
import (
"testing"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
)
func init() {
flag.StringVar(&MyFlag, "myflag", "default",
"myflag arg")
flag.Parse()
}
func RunE2ETests(t *testing.T) {
gomega.RegisterFailHandler(ginkgo.Fail)
ginkgo.RunSpecs(t, "e2e suite")
}
but when I start test using command "ginkgo --focus Casexxx -- --myflag flag", I got this error: flag provided but not defined: -test.timeout This problem seems to be the same as the one described in issue #602
hey - try it without calling flag.Parse
@onsi Thank you, this works for me!
I have a project like this: test\ e2e.go e2e_test.go case1.go case2.go .... when I trying to run tests by cli: ginkgo --label-filter=XXX --focus=XXX. Any flags I passing after ginkgo command not working, it seems just ignored. Almost every flags of ginkgo cli I'v tried, even -vv is not working here is code in e2e_test.go:
and code in e2e.go