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:
25
features/bdd_test.go
Normal file
25
features/bdd_test.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package features
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"DanceLessonsCoach/pkg/bdd"
|
||||
"github.com/cucumber/godog"
|
||||
)
|
||||
|
||||
func TestBDD(t *testing.T) {
|
||||
suite := godog.TestSuite{
|
||||
Name: "DanceLessonsCoach BDD Tests",
|
||||
TestSuiteInitializer: bdd.InitializeTestSuite,
|
||||
ScenarioInitializer: bdd.InitializeScenario,
|
||||
Options: &godog.Options{
|
||||
Format: "progress",
|
||||
Paths: []string{"."},
|
||||
TestingT: t,
|
||||
},
|
||||
}
|
||||
|
||||
if suite.Run() != 0 {
|
||||
t.Fatal("non-zero status returned, failed to run BDD tests")
|
||||
}
|
||||
}
|
||||
13
features/greet.feature
Normal file
13
features/greet.feature
Normal file
@@ -0,0 +1,13 @@
|
||||
# features/greet.feature
|
||||
Feature: Greet Service
|
||||
The greet service should return appropriate greetings
|
||||
|
||||
Scenario: Default greeting
|
||||
Given the server is running
|
||||
When I request the default greeting
|
||||
Then the response should be "{\"message\":\"Hello world!\"}"
|
||||
|
||||
Scenario: Personalized greeting
|
||||
Given the server is running
|
||||
When I request a greeting for "John"
|
||||
Then the response should be "{\"message\":\"Hello John!\"}"
|
||||
8
features/health.feature
Normal file
8
features/health.feature
Normal file
@@ -0,0 +1,8 @@
|
||||
# features/health.feature
|
||||
Feature: Health Endpoint
|
||||
The health endpoint should indicate server status
|
||||
|
||||
Scenario: Health check returns healthy status
|
||||
Given the server is running
|
||||
When I request the health endpoint
|
||||
Then the response should be "{\"status\":\"healthy\"}"
|
||||
Reference in New Issue
Block a user