🎲 feat: make test randomization seed configurable via GODOG_RANDOM_SEED
This commit is contained in:
@@ -150,6 +150,14 @@ func CreateTestSuite(t *testing.T, config *FeatureConfig, suiteName string) godo
|
||||
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
|
||||
// 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
|
||||
@@ -168,7 +176,7 @@ func CreateTestSuite(t *testing.T, config *FeatureConfig, suiteName string) godo
|
||||
Paths: []string{featurePath},
|
||||
TestingT: t,
|
||||
Strict: true,
|
||||
Randomize: -1,
|
||||
Randomize: randomize,
|
||||
StopOnFailure: stopOnFailure,
|
||||
Tags: tags,
|
||||
},
|
||||
@@ -195,6 +203,14 @@ func CreateMultiFeatureTestSuite(t *testing.T, config *MultiFeatureConfig, suite
|
||||
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{
|
||||
Name: suiteName,
|
||||
TestSuiteInitializer: bdd.InitializeTestSuite,
|
||||
@@ -204,7 +220,7 @@ func CreateMultiFeatureTestSuite(t *testing.T, config *MultiFeatureConfig, suite
|
||||
Paths: config.Paths,
|
||||
TestingT: t,
|
||||
Strict: true,
|
||||
Randomize: -1,
|
||||
Randomize: randomize,
|
||||
StopOnFailure: stopOnFailure,
|
||||
Tags: tags,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user