What I do
Create BDD tests with Gherkin syntax and godog steps.
When to use me
Adding integration/acceptance tests.
Pattern
- •Create step file:
test/steps/<feature>_steps.go - •Define context struct embedding BaseTestContext
- •Implement step methods
- •Register in InitializeScenario
Structure
go
type XxxContext struct { BaseTestContext }
func (c *XxxContext) StepName() error { ... }
func (c *XxxContext) InitializeScenario(ctx *godog.ScenarioContext) {
ctx.Step(`^pattern$`, c.StepName)
}
Commands (use Makefile)
bash
# Run BDD tests make test # Run specific test go test ./test -v
Rules
- •Use validation_helpers.go for common validations
- •Use HTTP client from http_client.go
- •Register context in suite_test.go
- •Use Given/When/Then pattern