From 4df20585b81becc45dd7e18266801b59ff416ab7 Mon Sep 17 00:00:00 2001 From: Gabriel Radureau Date: Fri, 10 Apr 2026 11:04:09 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20fix:=20standardize=20BDD=20test?= =?UTF-8?q?=20execution=20across=20all=20feature=20suites?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed path resolution in test setup to handle both feature-specific and multi-feature execution - Standardized stopOnFailure=false for all feature tests to ensure consistent behavior - Removed @todo tag from implemented Configuration validation scenario - Ensured GODOG_TAGS=todo go test ./features/X/... and FEATURE=X go test ./features/ run identical tests All feature suites (jwt, auth, greet, health, config) now behave consistently regardless of execution method. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- features/auth/auth_test.go | 2 +- features/greet/greet_test.go | 2 +- features/health/health_test.go | 2 +- features/jwt/jwt_secret_retention.feature | 1 - features/jwt/jwt_test.go | 2 +- pkg/bdd/testsetup/testsetup.go | 20 +++++++++++++++++++- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/features/auth/auth_test.go b/features/auth/auth_test.go index 39e698a..e627aa0 100644 --- a/features/auth/auth_test.go +++ b/features/auth/auth_test.go @@ -7,7 +7,7 @@ import ( ) func TestAuthBDD(t *testing.T) { - config := testsetup.NewFeatureConfig("auth", "progress", true) + config := testsetup.NewFeatureConfig("auth", "progress", false) suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - Auth Feature") if suite.Run() != 0 { diff --git a/features/greet/greet_test.go b/features/greet/greet_test.go index 2208fdc..f1f482d 100644 --- a/features/greet/greet_test.go +++ b/features/greet/greet_test.go @@ -7,7 +7,7 @@ import ( ) func TestGreetBDD(t *testing.T) { - config := testsetup.NewFeatureConfig("greet", "progress", true) + config := testsetup.NewFeatureConfig("greet", "progress", false) suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - Greet Feature") if suite.Run() != 0 { diff --git a/features/health/health_test.go b/features/health/health_test.go index 536630c..621fa25 100644 --- a/features/health/health_test.go +++ b/features/health/health_test.go @@ -7,7 +7,7 @@ import ( ) func TestHealthBDD(t *testing.T) { - config := testsetup.NewFeatureConfig("health", "progress", true) + config := testsetup.NewFeatureConfig("health", "progress", false) suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - Health Feature") if suite.Run() != 0 { diff --git a/features/jwt/jwt_secret_retention.feature b/features/jwt/jwt_secret_retention.feature index 1905a0e..f915cd5 100644 --- a/features/jwt/jwt_secret_retention.feature +++ b/features/jwt/jwt_secret_retention.feature @@ -83,7 +83,6 @@ Feature: JWT Secret Retention Policy And the old token should still be valid during retention period And both tokens should work until retention period expires - @todo Scenario: Configuration validation Given I set retention factor to 0.5 When I try to start the server diff --git a/features/jwt/jwt_test.go b/features/jwt/jwt_test.go index e1fb5e2..8c9472e 100644 --- a/features/jwt/jwt_test.go +++ b/features/jwt/jwt_test.go @@ -7,7 +7,7 @@ import ( ) func TestJWTBDD(t *testing.T) { - config := testsetup.NewFeatureConfig("jwt", "pretty", true) + config := testsetup.NewFeatureConfig("jwt", "pretty", false) suite := testsetup.CreateTestSuite(t, config, "dance-lessons-coach BDD Tests - JWT Feature") if suite.Run() != 0 { diff --git a/pkg/bdd/testsetup/testsetup.go b/pkg/bdd/testsetup/testsetup.go index 611c52d..85756ee 100644 --- a/pkg/bdd/testsetup/testsetup.go +++ b/pkg/bdd/testsetup/testsetup.go @@ -14,6 +14,15 @@ import ( "github.com/cucumber/godog" ) +// getWorkingDir returns the current working directory +func getWorkingDir() string { + dir, err := os.Getwd() + if err != nil { + return "unknown" + } + return dir +} + // FeatureConfig holds configuration for a feature test type FeatureConfig struct { FeatureName string @@ -141,13 +150,22 @@ func CreateTestSuite(t *testing.T, config *FeatureConfig, suiteName string) godo stopOnFailure, _ = strconv.ParseBool(envStop) } + // 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 + featurePath := "." + if workingDir := getWorkingDir(); !strings.HasSuffix(workingDir, "/"+config.FeatureName) && !strings.HasSuffix(workingDir, "\\"+config.FeatureName) { + // Not running from within the feature directory, use feature name + featurePath = config.FeatureName + } + return godog.TestSuite{ Name: suiteName, TestSuiteInitializer: bdd.InitializeTestSuite, ScenarioInitializer: bdd.InitializeScenario, Options: &godog.Options{ Format: config.Format, - Paths: []string{"."}, + Paths: []string{featurePath}, TestingT: t, Strict: true, Randomize: -1,