I’m using Godog to perform Cucumber tests in my Go API. My tests are defined in .feature files with scenarios tagged accordingly. I’m looking for a way to run scenarios based on tags, where scenarios are executed only if specific tags are fully matched. For example, consider the following scenarios:
@a
@b
Scenario: Scenario 1
...
@a
Scenario: Scenario 2
...
@a
@c
Scenario: Scenario 3
...
I want Scenario 3 to only be executed when BOTH a
AND c
are specified. Currently, if I specify a
, it will run all scenarios.
I’ve attempted to implement this using the following Go code snippet (simplified):
func (m ScenarioManager) GetTags() string {
tags := m.Environment
if tag := GetTags(); tag != "" {
tags += " && " + tag
}
return tags
}
func TestGenericScenario(t *testing.T) {
env := GetEnvironment()
apiConfig, err := suite.ParseConfigFile(GetEndpointConfigFilePath(), env)
...
manager := ScenarioManager{Environment: env, ApiConfig: apiConfig}
tests := godog.TestSuite{
ScenarioInitializer: manager.InitializeScenario,
Options: &godog.Options{
...
Tags: manager.GetTags(),
Concurrency: 1,
},
}
if tests.Run() != 0 {
t.Fatal("non-zero status returned, failed to run feature tests")
}
}
I thought that using the && operator would do the trick, but it’s not.
Thank you.
wzdmeister is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.