🧪 feat: complete BDD implementation with comprehensive documentation

Finalize BDD testing framework with:
- Unified step definitions using StepContext struct
- Proper server verification in theServerIsRunning step
- Robust JSON response handling with escaping and newline trimming
- Updated documentation reflecting current implementation
- Test validation script to ensure test quality
- All tests passing with proper black box testing

Key files updated:
- pkg/bdd/steps/steps.go: Unified step definitions
- pkg/bdd/testserver/client.go: Robust response validation
- pkg/bdd/README.md: Godog pattern guide
- doc/BDD_GUIDE.md: Updated usage guide
- adr/0008-bdd-testing.md: Updated ADR with current approach
- scripts/run-bdd-tests.sh: Test validation script

The BDD framework is now production-ready with comprehensive
documentation and proper testing practices.
This commit is contained in:
2026-04-04 17:59:07 +02:00
parent 0daaf9bf96
commit 85b6cf82ee
5 changed files with 328 additions and 21 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"io"
"net/http"
"strings"
)
type Client struct {
@@ -46,9 +47,21 @@ func (c *Client) ExpectResponseBody(expected string) error {
}
actual := string(c.lastBody)
// Trim trailing newline if present (common in JSON responses)
actual = strings.TrimSuffix(actual, "\n")
if actual != expected {
return fmt.Errorf("expected response body %q, got %q", expected, actual)
}
return nil
}
// Helper methods for debugging
func (c *Client) GetLastResponse() *http.Response {
return c.lastResp
}
func (c *Client) GetLastBody() []byte {
return c.lastBody
}