- 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>
33 lines
787 B
Go
33 lines
787 B
Go
package features
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"dance-lessons-coach/pkg/bdd/testsetup"
|
|
)
|
|
|
|
func TestBDD(t *testing.T) {
|
|
// Get feature name from environment variable or default to all features
|
|
feature := testsetup.GetFeatureFromEnv()
|
|
|
|
var suiteName string
|
|
var paths []string
|
|
|
|
if feature == "" {
|
|
// Run all features
|
|
suiteName = "dance-lessons-coach BDD Tests - All Features"
|
|
paths = testsetup.GetAllFeaturePaths()
|
|
} else {
|
|
// Run specific feature
|
|
suiteName = "dance-lessons-coach BDD Tests - " + feature + " Feature"
|
|
paths = []string{feature}
|
|
}
|
|
|
|
config := testsetup.NewMultiFeatureConfig(paths, "progress", false)
|
|
suite := testsetup.CreateMultiFeatureTestSuite(t, config, suiteName)
|
|
|
|
if suite.Run() != 0 {
|
|
t.Fatal("non-zero status returned, failed to run BDD tests")
|
|
}
|
|
}
|