♻️ refactor: make BDD test setup DRY with shared testsetup package
- Create pkg/bdd/testsetup package with shared test configuration functions - Refactor all feature test files to use shared setup (70+ lines reduced) - Implement dynamic feature path detection by scanning filesystem for directories - Add getProjectRoot() function to find project root via go.mod - Maintain all existing functionality (tags, stop on failure, etc.) - Add fallback to hardcoded paths if filesystem access fails - Sort feature paths for consistent test execution order Before: ~35 lines per test file with duplicated setup code After: ~5 lines per test file using shared functions Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistralai.com>
This commit is contained in:
@@ -1,45 +1,14 @@
|
|||||||
package auth
|
package auth
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"dance-lessons-coach/pkg/bdd"
|
"dance-lessons-coach/pkg/bdd/testsetup"
|
||||||
|
|
||||||
"github.com/cucumber/godog"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAuthBDD(t *testing.T) {
|
func TestAuthBDD(t *testing.T) {
|
||||||
// Set FEATURE environment variable for feature-specific configuration
|
config := testsetup.NewFeatureConfig("auth", "progress", true)
|
||||||
os.Setenv("FEATURE", "auth")
|
suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - Auth Feature")
|
||||||
|
|
||||||
// Allow tag override via environment variable
|
|
||||||
tags := os.Getenv("GODOG_TAGS")
|
|
||||||
if tags == "" {
|
|
||||||
// Default tags if not overridden
|
|
||||||
tags = "~@flaky && ~@todo && ~@skip"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow stop on failure override via environment variable
|
|
||||||
stopOnFailure := true // Default for auth tests
|
|
||||||
if envStop := os.Getenv("GODOG_STOP_ON_FAILURE"); envStop != "" {
|
|
||||||
stopOnFailure = envStop == "true" || envStop == "1"
|
|
||||||
}
|
|
||||||
|
|
||||||
suite := godog.TestSuite{
|
|
||||||
Name: "dance-lessons-coach BDD Tests - Auth Feature",
|
|
||||||
TestSuiteInitializer: bdd.InitializeTestSuite,
|
|
||||||
ScenarioInitializer: bdd.InitializeScenario,
|
|
||||||
Options: &godog.Options{
|
|
||||||
Format: "progress",
|
|
||||||
Paths: []string{"."},
|
|
||||||
TestingT: t,
|
|
||||||
Strict: true,
|
|
||||||
Randomize: -1,
|
|
||||||
StopOnFailure: stopOnFailure,
|
|
||||||
Tags: tags,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if suite.Run() != 0 {
|
if suite.Run() != 0 {
|
||||||
t.Fatal("non-zero status returned, failed to run auth BDD tests")
|
t.Fatal("non-zero status returned, failed to run auth BDD tests")
|
||||||
|
|||||||
@@ -1,64 +1,30 @@
|
|||||||
package features
|
package features
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"dance-lessons-coach/pkg/bdd"
|
"dance-lessons-coach/pkg/bdd/testsetup"
|
||||||
|
|
||||||
"github.com/cucumber/godog"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBDD(t *testing.T) {
|
func TestBDD(t *testing.T) {
|
||||||
// Get feature name from environment variable or default to all features
|
// Get feature name from environment variable or default to all features
|
||||||
feature := os.Getenv("FEATURE")
|
feature := testsetup.GetFeatureFromEnv()
|
||||||
|
|
||||||
var paths []string
|
|
||||||
var suiteName string
|
var suiteName string
|
||||||
|
var paths []string
|
||||||
|
|
||||||
if feature == "" {
|
if feature == "" {
|
||||||
// Run all features
|
// Run all features
|
||||||
suiteName = "dance-lessons-coach BDD Tests - All Features"
|
suiteName = "dance-lessons-coach BDD Tests - All Features"
|
||||||
paths = []string{
|
paths = testsetup.GetAllFeaturePaths()
|
||||||
"auth",
|
|
||||||
"config",
|
|
||||||
"greet",
|
|
||||||
"health",
|
|
||||||
"jwt",
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Run specific feature
|
// Run specific feature
|
||||||
suiteName = "dance-lessons-coach BDD Tests - " + feature + " Feature"
|
suiteName = "dance-lessons-coach BDD Tests - " + feature + " Feature"
|
||||||
paths = []string{feature}
|
paths = []string{feature}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow tag override via environment variable
|
config := testsetup.NewMultiFeatureConfig(paths, "progress", false)
|
||||||
tags := os.Getenv("GODOG_TAGS")
|
suite := testsetup.CreateMultiFeatureTestSuite(t, config, suiteName)
|
||||||
if tags == "" {
|
|
||||||
// Default tags if not overridden
|
|
||||||
tags = "~@flaky && ~@todo && ~@skip"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow stop on failure override via environment variable
|
|
||||||
stopOnFailure := false // Default for all features test (don't stop on failure)
|
|
||||||
if envStop := os.Getenv("GODOG_STOP_ON_FAILURE"); envStop != "" {
|
|
||||||
stopOnFailure = envStop == "true" || envStop == "1"
|
|
||||||
}
|
|
||||||
|
|
||||||
suite := godog.TestSuite{
|
|
||||||
Name: suiteName,
|
|
||||||
TestSuiteInitializer: bdd.InitializeTestSuite,
|
|
||||||
ScenarioInitializer: bdd.InitializeScenario,
|
|
||||||
Options: &godog.Options{
|
|
||||||
Format: "progress",
|
|
||||||
Paths: paths,
|
|
||||||
TestingT: t,
|
|
||||||
Strict: true,
|
|
||||||
Randomize: -1,
|
|
||||||
StopOnFailure: stopOnFailure,
|
|
||||||
Tags: tags,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if suite.Run() != 0 {
|
if suite.Run() != 0 {
|
||||||
t.Fatal("non-zero status returned, failed to run BDD tests")
|
t.Fatal("non-zero status returned, failed to run BDD tests")
|
||||||
|
|||||||
@@ -1,45 +1,14 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"dance-lessons-coach/pkg/bdd"
|
"dance-lessons-coach/pkg/bdd/testsetup"
|
||||||
|
|
||||||
"github.com/cucumber/godog"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestConfigBDD(t *testing.T) {
|
func TestConfigBDD(t *testing.T) {
|
||||||
// Set FEATURE environment variable for feature-specific configuration
|
config := testsetup.NewFeatureConfig("config", "progress", false)
|
||||||
os.Setenv("FEATURE", "config")
|
suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - Config Feature")
|
||||||
|
|
||||||
// Allow tag override via environment variable
|
|
||||||
tags := os.Getenv("GODOG_TAGS")
|
|
||||||
if tags == "" {
|
|
||||||
// Default tags if not overridden
|
|
||||||
tags = "~@flaky && ~@todo && ~@skip"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow stop on failure override via environment variable
|
|
||||||
stopOnFailure := false // Default for config tests (don't stop on failure)
|
|
||||||
if envStop := os.Getenv("GODOG_STOP_ON_FAILURE"); envStop != "" {
|
|
||||||
stopOnFailure = envStop == "true" || envStop == "1"
|
|
||||||
}
|
|
||||||
|
|
||||||
suite := godog.TestSuite{
|
|
||||||
Name: "dance-lessons-coach BDD Tests - Config Feature",
|
|
||||||
TestSuiteInitializer: bdd.InitializeTestSuite,
|
|
||||||
ScenarioInitializer: bdd.InitializeScenario,
|
|
||||||
Options: &godog.Options{
|
|
||||||
Format: "progress",
|
|
||||||
Paths: []string{"."},
|
|
||||||
TestingT: t,
|
|
||||||
Strict: true,
|
|
||||||
Randomize: -1,
|
|
||||||
StopOnFailure: stopOnFailure,
|
|
||||||
Tags: tags,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if suite.Run() != 0 {
|
if suite.Run() != 0 {
|
||||||
t.Fatal("non-zero status returned, failed to run config BDD tests")
|
t.Fatal("non-zero status returned, failed to run config BDD tests")
|
||||||
|
|||||||
@@ -1,45 +1,14 @@
|
|||||||
package greet
|
package greet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"dance-lessons-coach/pkg/bdd"
|
"dance-lessons-coach/pkg/bdd/testsetup"
|
||||||
|
|
||||||
"github.com/cucumber/godog"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGreetBDD(t *testing.T) {
|
func TestGreetBDD(t *testing.T) {
|
||||||
// Set FEATURE environment variable for feature-specific configuration
|
config := testsetup.NewFeatureConfig("greet", "progress", true)
|
||||||
os.Setenv("FEATURE", "greet")
|
suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - Greet Feature")
|
||||||
|
|
||||||
// Allow tag override via environment variable
|
|
||||||
tags := os.Getenv("GODOG_TAGS")
|
|
||||||
if tags == "" {
|
|
||||||
// Default tags if not overridden
|
|
||||||
tags = "~@flaky && ~@todo && ~@skip"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow stop on failure override via environment variable
|
|
||||||
stopOnFailure := true // Default for greet tests
|
|
||||||
if envStop := os.Getenv("GODOG_STOP_ON_FAILURE"); envStop != "" {
|
|
||||||
stopOnFailure = envStop == "true" || envStop == "1"
|
|
||||||
}
|
|
||||||
|
|
||||||
suite := godog.TestSuite{
|
|
||||||
Name: "dance-lessons-coach BDD Tests - Greet Feature",
|
|
||||||
TestSuiteInitializer: bdd.InitializeTestSuite,
|
|
||||||
ScenarioInitializer: bdd.InitializeScenario,
|
|
||||||
Options: &godog.Options{
|
|
||||||
Format: "progress",
|
|
||||||
Paths: []string{"."},
|
|
||||||
TestingT: t,
|
|
||||||
Strict: true,
|
|
||||||
Randomize: -1,
|
|
||||||
StopOnFailure: stopOnFailure,
|
|
||||||
Tags: tags,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if suite.Run() != 0 {
|
if suite.Run() != 0 {
|
||||||
t.Fatal("non-zero status returned, failed to run greet BDD tests")
|
t.Fatal("non-zero status returned, failed to run greet BDD tests")
|
||||||
|
|||||||
@@ -1,45 +1,14 @@
|
|||||||
package health
|
package health
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"dance-lessons-coach/pkg/bdd"
|
"dance-lessons-coach/pkg/bdd/testsetup"
|
||||||
|
|
||||||
"github.com/cucumber/godog"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestHealthBDD(t *testing.T) {
|
func TestHealthBDD(t *testing.T) {
|
||||||
// Set FEATURE environment variable for feature-specific configuration
|
config := testsetup.NewFeatureConfig("health", "progress", true)
|
||||||
os.Setenv("FEATURE", "health")
|
suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - Health Feature")
|
||||||
|
|
||||||
// Allow tag override via environment variable
|
|
||||||
tags := os.Getenv("GODOG_TAGS")
|
|
||||||
if tags == "" {
|
|
||||||
// Default tags if not overridden
|
|
||||||
tags = "~@flaky && ~@todo && ~@skip"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow stop on failure override via environment variable
|
|
||||||
stopOnFailure := true // Default for health tests
|
|
||||||
if envStop := os.Getenv("GODOG_STOP_ON_FAILURE"); envStop != "" {
|
|
||||||
stopOnFailure = envStop == "true" || envStop == "1"
|
|
||||||
}
|
|
||||||
|
|
||||||
suite := godog.TestSuite{
|
|
||||||
Name: "dance-lessons-coach BDD Tests - Health Feature",
|
|
||||||
TestSuiteInitializer: bdd.InitializeTestSuite,
|
|
||||||
ScenarioInitializer: bdd.InitializeScenario,
|
|
||||||
Options: &godog.Options{
|
|
||||||
Format: "progress",
|
|
||||||
Paths: []string{"."},
|
|
||||||
TestingT: t,
|
|
||||||
Strict: true,
|
|
||||||
Randomize: -1,
|
|
||||||
StopOnFailure: stopOnFailure,
|
|
||||||
Tags: tags,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if suite.Run() != 0 {
|
if suite.Run() != 0 {
|
||||||
t.Fatal("non-zero status returned, failed to run health BDD tests")
|
t.Fatal("non-zero status returned, failed to run health BDD tests")
|
||||||
|
|||||||
@@ -1,45 +1,14 @@
|
|||||||
package jwt
|
package jwt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"dance-lessons-coach/pkg/bdd"
|
"dance-lessons-coach/pkg/bdd/testsetup"
|
||||||
|
|
||||||
"github.com/cucumber/godog"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestJWTBDD(t *testing.T) {
|
func TestJWTBDD(t *testing.T) {
|
||||||
// Set FEATURE environment variable for feature-specific configuration
|
config := testsetup.NewFeatureConfig("jwt", "pretty", true)
|
||||||
os.Setenv("FEATURE", "jwt")
|
suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - JWT Feature")
|
||||||
|
|
||||||
// Allow tag override via environment variable
|
|
||||||
tags := os.Getenv("GODOG_TAGS")
|
|
||||||
if tags == "" {
|
|
||||||
// Default tags if not overridden
|
|
||||||
tags = "~@flaky && ~@todo && ~@skip"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow stop on failure override via environment variable
|
|
||||||
stopOnFailure := true // Default for JWT tests
|
|
||||||
if envStop := os.Getenv("GODOG_STOP_ON_FAILURE"); envStop != "" {
|
|
||||||
stopOnFailure = envStop == "true" || envStop == "1"
|
|
||||||
}
|
|
||||||
|
|
||||||
suite := godog.TestSuite{
|
|
||||||
Name: "dance-lessons-coach BDD Tests - JWT Feature",
|
|
||||||
TestSuiteInitializer: bdd.InitializeTestSuite,
|
|
||||||
ScenarioInitializer: bdd.InitializeScenario,
|
|
||||||
Options: &godog.Options{
|
|
||||||
Format: "pretty",
|
|
||||||
Paths: []string{"."},
|
|
||||||
TestingT: t,
|
|
||||||
Strict: true,
|
|
||||||
Randomize: -1,
|
|
||||||
StopOnFailure: stopOnFailure,
|
|
||||||
Tags: tags,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
if suite.Run() != 0 {
|
if suite.Run() != 0 {
|
||||||
t.Fatal("non-zero status returned, failed to run jwt BDD tests")
|
t.Fatal("non-zero status returned, failed to run jwt BDD tests")
|
||||||
|
|||||||
194
pkg/bdd/testsetup/testsetup.go
Normal file
194
pkg/bdd/testsetup/testsetup.go
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
package testsetup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"dance-lessons-coach/pkg/bdd"
|
||||||
|
|
||||||
|
"github.com/cucumber/godog"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FeatureConfig holds configuration for a feature test
|
||||||
|
type FeatureConfig struct {
|
||||||
|
FeatureName string
|
||||||
|
Format string
|
||||||
|
StopOnFailure bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// MultiFeatureConfig holds configuration for multi-feature tests
|
||||||
|
type MultiFeatureConfig struct {
|
||||||
|
Paths []string
|
||||||
|
Format string
|
||||||
|
StopOnFailure bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewFeatureConfig creates a new feature configuration
|
||||||
|
func NewFeatureConfig(featureName, format string, stopOnFailure bool) *FeatureConfig {
|
||||||
|
return &FeatureConfig{
|
||||||
|
FeatureName: featureName,
|
||||||
|
Format: format,
|
||||||
|
StopOnFailure: stopOnFailure,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMultiFeatureConfig creates a new multi-feature configuration
|
||||||
|
func NewMultiFeatureConfig(paths []string, format string, stopOnFailure bool) *MultiFeatureConfig {
|
||||||
|
return &MultiFeatureConfig{
|
||||||
|
Paths: paths,
|
||||||
|
Format: format,
|
||||||
|
StopOnFailure: stopOnFailure,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetFeatureFromEnv gets the feature name from environment variable
|
||||||
|
func GetFeatureFromEnv() string {
|
||||||
|
return os.Getenv("FEATURE")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAllFeaturePaths returns paths for all features by scanning the filesystem
|
||||||
|
func GetAllFeaturePaths() []string {
|
||||||
|
// Get the project root directory
|
||||||
|
projectRoot, err := getProjectRoot()
|
||||||
|
if err != nil {
|
||||||
|
// Fallback to hardcoded list if we can't determine project root
|
||||||
|
return []string{
|
||||||
|
"auth",
|
||||||
|
"config",
|
||||||
|
"greet",
|
||||||
|
"health",
|
||||||
|
"jwt",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the features directory from project root
|
||||||
|
featuresPath := filepath.Join(projectRoot, "features")
|
||||||
|
entries, err := os.ReadDir(featuresPath)
|
||||||
|
if err != nil {
|
||||||
|
// Fallback to hardcoded list if filesystem access fails
|
||||||
|
return []string{
|
||||||
|
"auth",
|
||||||
|
"config",
|
||||||
|
"greet",
|
||||||
|
"health",
|
||||||
|
"jwt",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var paths []string
|
||||||
|
for _, entry := range entries {
|
||||||
|
// Only include directories (features) that are not hidden and not test files
|
||||||
|
if entry.IsDir() && !strings.HasPrefix(entry.Name(), ".") {
|
||||||
|
paths = append(paths, entry.Name())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort paths for consistent ordering
|
||||||
|
sort.Strings(paths)
|
||||||
|
|
||||||
|
return paths
|
||||||
|
}
|
||||||
|
|
||||||
|
// getProjectRoot finds the project root directory by looking for go.mod
|
||||||
|
func getProjectRoot() (string, error) {
|
||||||
|
// Start from current directory and walk up the tree
|
||||||
|
dir, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Walk up the directory tree until we find go.mod or reach root
|
||||||
|
for {
|
||||||
|
// Check if go.mod exists in current directory
|
||||||
|
if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil {
|
||||||
|
return dir, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move up one directory
|
||||||
|
parent := filepath.Dir(dir)
|
||||||
|
if parent == dir {
|
||||||
|
// Reached root directory
|
||||||
|
break
|
||||||
|
}
|
||||||
|
dir = parent
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we get here, we didn't find go.mod - return original working directory
|
||||||
|
return "", fmt.Errorf("could not find project root (go.mod not found)")
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateTestSuite creates a configured godog test suite
|
||||||
|
func CreateTestSuite(t *testing.T, config *FeatureConfig, suiteName string) godog.TestSuite {
|
||||||
|
// Set FEATURE environment variable for feature-specific configuration
|
||||||
|
os.Setenv("FEATURE", config.FeatureName)
|
||||||
|
|
||||||
|
// Allow tag override via environment variable
|
||||||
|
tags := os.Getenv("GODOG_TAGS")
|
||||||
|
if tags == "" {
|
||||||
|
// Default tags if not overridden
|
||||||
|
tags = "~@flaky && ~@todo && ~@skip"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow stop on failure override via environment variable
|
||||||
|
stopOnFailure := config.StopOnFailure
|
||||||
|
if envStop := os.Getenv("GODOG_STOP_ON_FAILURE"); envStop != "" {
|
||||||
|
// Support various boolean formats
|
||||||
|
stopOnFailure, _ = strconv.ParseBool(envStop)
|
||||||
|
}
|
||||||
|
|
||||||
|
return godog.TestSuite{
|
||||||
|
Name: suiteName,
|
||||||
|
TestSuiteInitializer: bdd.InitializeTestSuite,
|
||||||
|
ScenarioInitializer: bdd.InitializeScenario,
|
||||||
|
Options: &godog.Options{
|
||||||
|
Format: config.Format,
|
||||||
|
Paths: []string{"."},
|
||||||
|
TestingT: t,
|
||||||
|
Strict: true,
|
||||||
|
Randomize: -1,
|
||||||
|
StopOnFailure: stopOnFailure,
|
||||||
|
Tags: tags,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateMultiFeatureTestSuite creates a configured godog test suite for multiple features
|
||||||
|
func CreateMultiFeatureTestSuite(t *testing.T, config *MultiFeatureConfig, suiteName string) godog.TestSuite {
|
||||||
|
// Set FEATURE environment variable for feature-specific configuration
|
||||||
|
// For multi-feature tests, we don't set a specific feature
|
||||||
|
os.Setenv("FEATURE", "")
|
||||||
|
|
||||||
|
// Allow tag override via environment variable
|
||||||
|
tags := os.Getenv("GODOG_TAGS")
|
||||||
|
if tags == "" {
|
||||||
|
// Default tags if not overridden
|
||||||
|
tags = "~@flaky && ~@todo && ~@skip"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow stop on failure override via environment variable
|
||||||
|
stopOnFailure := config.StopOnFailure
|
||||||
|
if envStop := os.Getenv("GODOG_STOP_ON_FAILURE"); envStop != "" {
|
||||||
|
// Support various boolean formats
|
||||||
|
stopOnFailure, _ = strconv.ParseBool(envStop)
|
||||||
|
}
|
||||||
|
|
||||||
|
return godog.TestSuite{
|
||||||
|
Name: suiteName,
|
||||||
|
TestSuiteInitializer: bdd.InitializeTestSuite,
|
||||||
|
ScenarioInitializer: bdd.InitializeScenario,
|
||||||
|
Options: &godog.Options{
|
||||||
|
Format: config.Format,
|
||||||
|
Paths: config.Paths,
|
||||||
|
TestingT: t,
|
||||||
|
Strict: true,
|
||||||
|
Randomize: -1,
|
||||||
|
StopOnFailure: stopOnFailure,
|
||||||
|
Tags: tags,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user