🎲 feat: make test randomization seed configurable via GODOG_RANDOM_SEED
Some checks failed
CI/CD Pipeline / Build Docker Cache (push) Successful in 9s
CI/CD Pipeline / CI Pipeline (push) Has been cancelled

This commit is contained in:
2026-04-10 17:35:47 +02:00
parent 908e41ba7d
commit 3dbd41b731

View File

@@ -150,6 +150,14 @@ func CreateTestSuite(t *testing.T, config *FeatureConfig, suiteName string) godo
stopOnFailure, _ = strconv.ParseBool(envStop) stopOnFailure, _ = strconv.ParseBool(envStop)
} }
// Allow randomization seed override via environment variable
randomize := -1 // Default: randomize test order
if envSeed := os.Getenv("GODOG_RANDOM_SEED"); envSeed != "" {
if parsedSeed, err := strconv.Atoi(envSeed); err == nil {
randomize = parsedSeed
}
}
// Determine the correct path for feature files // Determine the correct path for feature files
// When running from within a feature directory, use "." to find feature files in current dir // When running from within a feature directory, use "." to find feature files in current dir
// When running from outside, use the feature name as a relative path // When running from outside, use the feature name as a relative path
@@ -168,7 +176,7 @@ func CreateTestSuite(t *testing.T, config *FeatureConfig, suiteName string) godo
Paths: []string{featurePath}, Paths: []string{featurePath},
TestingT: t, TestingT: t,
Strict: true, Strict: true,
Randomize: -1, Randomize: randomize,
StopOnFailure: stopOnFailure, StopOnFailure: stopOnFailure,
Tags: tags, Tags: tags,
}, },
@@ -195,6 +203,14 @@ func CreateMultiFeatureTestSuite(t *testing.T, config *MultiFeatureConfig, suite
stopOnFailure, _ = strconv.ParseBool(envStop) stopOnFailure, _ = strconv.ParseBool(envStop)
} }
// Allow randomization seed override via environment variable
randomize := -1 // Default: randomize test order
if envSeed := os.Getenv("GODOG_RANDOM_SEED"); envSeed != "" {
if parsedSeed, err := strconv.Atoi(envSeed); err == nil {
randomize = parsedSeed
}
}
return godog.TestSuite{ return godog.TestSuite{
Name: suiteName, Name: suiteName,
TestSuiteInitializer: bdd.InitializeTestSuite, TestSuiteInitializer: bdd.InitializeTestSuite,
@@ -204,7 +220,7 @@ func CreateMultiFeatureTestSuite(t *testing.T, config *MultiFeatureConfig, suite
Paths: config.Paths, Paths: config.Paths,
TestingT: t, TestingT: t,
Strict: true, Strict: true,
Randomize: -1, Randomize: randomize,
StopOnFailure: stopOnFailure, StopOnFailure: stopOnFailure,
Tags: tags, Tags: tags,
}, },