feat: implement BDD testing with Godog
Implement comprehensive BDD testing framework using Godog: - Added feature files for greet and health endpoints - Created test server that runs on port 9191 - Implemented step definitions using Godog's exact patterns - Fixed undefined step warnings by following Godog conventions - All tests passing with proper response validation - Maintained black box testing principles Key files: - pkg/bdd/steps/steps.go - Step definitions using StepContext struct - pkg/bdd/testserver/ - Test server implementation - features/*.feature - BDD feature files - pkg/bdd/README.md - Documentation for proper step patterns The implementation follows Godog's exact pattern suggestions to avoid undefined step warnings and provides comprehensive API testing.
This commit is contained in:
29
pkg/bdd/suite.go
Normal file
29
pkg/bdd/suite.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package bdd
|
||||
|
||||
import (
|
||||
"DanceLessonsCoach/pkg/bdd/steps"
|
||||
"DanceLessonsCoach/pkg/bdd/testserver"
|
||||
"github.com/cucumber/godog"
|
||||
)
|
||||
|
||||
var sharedServer *testserver.Server
|
||||
|
||||
func InitializeTestSuite(ctx *godog.TestSuiteContext) {
|
||||
ctx.BeforeSuite(func() {
|
||||
sharedServer = testserver.NewServer()
|
||||
if err := sharedServer.Start(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
})
|
||||
|
||||
ctx.AfterSuite(func() {
|
||||
if sharedServer != nil {
|
||||
sharedServer.Stop()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||
client := testserver.NewClient(sharedServer)
|
||||
steps.InitializeAllSteps(ctx, client)
|
||||
}
|
||||
Reference in New Issue
Block a user