Documentation
¶
Overview ¶
Package bdd wraps github.com/go-bdd/gobdd so hex applications can write behavior-driven tests with standard Gherkin `.feature` files.
The wrapper adds:
- Type aliases so consumers get the full gobdd API through hex.
- Option re-exports for common configuration.
- NewSuite for the typical on-disk feature-file setup.
- NewSuiteFS which materialises `//go:embed`-ed features into a temp directory at test time, then points gobdd at that directory.
See ADR-0015.
Example (embed.FS):
//go:embed features/*.feature
var featuresFS embed.FS
func TestFeatures(t *testing.T) {
suite := bdd.NewSuiteFS(t, featuresFS, "features/*.feature")
suite.AddStep(`I have (\d+) items`, hasItems)
suite.AddStep(`I remove (\d+) items`, removeItems)
suite.Run()
}
Index ¶
- type Context
- type Option
- func RunInParallel() Option
- func WithAfterScenario(fn func(Context)) Option
- func WithAfterStep(fn func(Context)) Option
- func WithBeforeScenario(fn func(Context)) Option
- func WithBeforeStep(fn func(Context)) Option
- func WithFeaturesPath(path string) Option
- func WithIgnoredTags(tags ...string) Option
- func WithTags(tags ...string) Option
- type StepTest
- type Suite
- type SuiteOptions
- type TestingT
- type TestingTB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
Context is the type alias for the per-scenario Context passed to step functions and lifecycle hooks.
type Option ¶
type Option = func(*gobdd.SuiteOptions)
Option is a functional option for the suite.
func WithAfterScenario ¶
WithAfterScenario registers a hook run after each scenario.
func WithAfterStep ¶
WithAfterStep registers a hook run after each step.
func WithBeforeScenario ¶
WithBeforeScenario registers a hook run before each scenario.
func WithBeforeStep ¶
WithBeforeStep registers a hook run before each step.
func WithFeaturesPath ¶
WithFeaturesPath overrides the default `features/*.feature` glob with path. Useful when features live outside the conventional directory.
func WithIgnoredTags ¶
WithIgnoredTags skips scenarios carrying any of the given tags.
type Suite ¶
Suite is the type alias for gobdd's test suite.
func NewSuite ¶
NewSuite is a passthrough constructor for the on-disk case. Equivalent to gobdd.NewSuite but returns the hex-aliased type.
func NewSuiteFS ¶
NewSuiteFS materialises feature files matching glob from f into a temporary directory and returns a Suite pointing at that directory. The temp directory is cleaned up when t completes.
Use this when feature files are embedded via //go:embed so the tests can run against a fully compiled binary without carrying the feature files on disk at runtime.
glob is a fs.Glob pattern relative to f's root. Passing "" defaults to "features/*.feature".
type SuiteOptions ¶
type SuiteOptions = gobdd.SuiteOptions
SuiteOptions is the type alias for gobdd's option bag.