Repository: go-bdd/gobdd
Pull request #136 (2021-05-05 12:48:52)

use varadic func for WithTags and WithIgnoredTags #135
Fixes https://github.com/go-bdd/gobdd/issues/135

bkielbasa: Hi! Thanks for your submission! I like the change you suggested. The only problem with it it's not backward compatible change. Maybe it's the time we should release the v2 version and do some cleanups... any thoughts @sagikazarmark?

Patch:
diff --git a/docs/suite-options.md b/docs/suite-options.md
index 1bf1a07..1b3d8ad 100644
--- a/docs/suite-options.md
+++ b/docs/suite-options.md
@@ -9,10 +9,10 @@ The suite can be confiugred using one of these functions:
 
 * `RunInParallel()` - enables running steps in parallel. It uses the stanard `T.Parallel` function.
 * `WithFeaturesPath(path string)` - configures the path where GoBDD should look for features. The default value is `features/*.feature`.
-* `WithTags(tags []string)` - configures which tags should be run. Every tag has to start with `@`.
+* `WithTags(tags ...string)` - configures which tags should be run. Every tag has to start with `@`.
 * `WithBeforeScenario(f func())` - this function `f` will be called before every scenario.
 * `WithAfterScenario(f func())` - this funcion `f` will be called after every scenario.
-* `WithIgnoredTags(tags []string)` - configures tags which should be ignored and excluded from execution.
+* `WithIgnoredTags(tags ...string)` - configures tags which should be ignored and excluded from execution.
 
 ## Usage
 
diff --git a/gobdd.go b/gobdd.go
index d3cee26..898d57b 100644
--- a/gobdd.go
+++ b/gobdd.go
@@ -67,7 +67,7 @@ func WithFeaturesPath(path string) func(*SuiteOptions) {
 
 // WithTags configures which tags should be skipped while executing a suite
 // Every tag has to start with @
-func WithTags(tags []string) func(*SuiteOptions) {
+func WithTags(tags ...string) func(*SuiteOptions) {
 	return func(options *SuiteOptions) {
 		options.tags = tags
 	}
@@ -103,7 +103,7 @@ func WithAfterStep(f func(ctx Context)) func(*SuiteOptions) {
 
 // WithIgnoredTags configures which tags should be skipped while executing a suite
 // Every tag has to start with @ otherwise will be ignored
-func WithIgnoredTags(tags []string) func(*SuiteOptions) {
+func WithIgnoredTags(tags ...string) func(*SuiteOptions) {
 	return func(options *SuiteOptions) {
 		options.ignoreTags = tags
 	}


Test patch:
diff --git a/gobdd_test.go b/gobdd_test.go
index 9c373a0..b269cfb 100644
--- a/gobdd_test.go
+++ b/gobdd_test.go
@@ -111,7 +111,7 @@ func TestBackground(t *testing.T) {
 }
 
 func TestTags(t *testing.T) {
-	suite := NewSuite(t, WithFeaturesPath("features/tags.feature"), WithTags([]string{"@tag"}))
+	suite := NewSuite(t, WithFeaturesPath("features/tags.feature"), WithTags("@tag"))
 	suite.AddStep(`fail the test`, fail)
 	suite.AddStep(`the test should pass`, pass)
 
@@ -119,7 +119,7 @@ func TestTags(t *testing.T) {
 }
 
 func TestFilterFeatureWithTags(t *testing.T) {
-	suite := NewSuite(t, WithFeaturesPath("features/filter_tags_*.feature"), WithTags([]string{"@run-this"}))
+	suite := NewSuite(t, WithFeaturesPath("features/filter_tags_*.feature"), WithTags("@run-this"))
 	c := false
 
 	suite.AddStep(`the test should pass`, func(_ StepTest, _ Context) {
@@ -189,13 +189,13 @@ func TestWithBeforeStep(t *testing.T) {
 }
 
 func TestIgnoredTags(t *testing.T) {
-	suite := NewSuite(t, WithFeaturesPath("features/ignored_tags.feature"), WithIgnoredTags([]string{"@ignore"}))
+	suite := NewSuite(t, WithFeaturesPath("features/ignored_tags.feature"), WithIgnoredTags("@ignore"))
 	suite.AddStep(`fail the test`, fail)
 	suite.Run()
 }
 
 func TestIgnorFeatureWithTags(t *testing.T) {
-	suite := NewSuite(t, WithFeaturesPath("features/ignored_feature_tags.feature"), WithIgnoredTags([]string{"@ignore"}))
+	suite := NewSuite(t, WithFeaturesPath("features/ignored_feature_tags.feature"), WithIgnoredTags("@ignore"))
 	suite.AddStep(`fail the test`, fail)
 	suite.Run()
 }