From 6a92046b524eb94398e5df22d2f3b31abc227e49 Mon Sep 17 00:00:00 2001 From: Viacheslav Poturaev Date: Fri, 12 Aug 2022 01:09:53 +0200 Subject: [PATCH] Use godog flags --- test/feature.go | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/test/feature.go b/test/feature.go index a63ee92..de641e9 100644 --- a/test/feature.go +++ b/test/feature.go @@ -52,7 +52,19 @@ func newContext(t *testing.T) *Context { return tc } -var feature = flag.String("feature", "features", "Feature file to test.") +var ( + feature = flag.String("feature", "features", "Feature file to test.") + godogOptions = godog.Options{ + Format: "pretty-failed", + Strict: true, + Tags: os.Getenv("GODOG_TAGS"), + StopOnFailure: os.Getenv("GODOG_STOP_ON_FAILURE") == "1", + } +) + +func init() { + godog.BindFlags("godog.", flag.CommandLine, &godogOptions) +} // RunFeatures runs feature tests. func RunFeatures(t *testing.T, envPrefix string, cfg brick.WithBaseConfig, init func(tc *Context) (*brick.BaseLocator, http.Handler)) { @@ -78,14 +90,15 @@ func RunFeatures(t *testing.T, envPrefix string, cfg brick.WithBaseConfig, init godogx.RegisterPrettyFailedFormatter() - options := godog.Options{ - Format: "pretty-failed", - Strict: true, - Paths: []string{*feature}, - Tags: os.Getenv("GODOG_TAGS"), - StopOnFailure: os.Getenv("GODOG_STOP_ON_FAILURE") == "1", - TestingT: t, - Concurrency: tc.Concurrency, + options := godogOptions + + options.TestingT = t + if options.Concurrency == 0 { + options.Concurrency = tc.Concurrency + } + + if len(options.Paths) == 0 { + options.Paths = []string{*feature} } if tc.OptionsInitializer != nil {