bdd

package
v0.0.2-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context = gobdd.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 RunInParallel

func RunInParallel() Option

RunInParallel enables parallel scenario execution.

func WithAfterScenario

func WithAfterScenario(fn func(Context)) Option

WithAfterScenario registers a hook run after each scenario.

func WithAfterStep

func WithAfterStep(fn func(Context)) Option

WithAfterStep registers a hook run after each step.

func WithBeforeScenario

func WithBeforeScenario(fn func(Context)) Option

WithBeforeScenario registers a hook run before each scenario.

func WithBeforeStep

func WithBeforeStep(fn func(Context)) Option

WithBeforeStep registers a hook run before each step.

func WithFeaturesPath

func WithFeaturesPath(path string) Option

WithFeaturesPath overrides the default `features/*.feature` glob with path. Useful when features live outside the conventional directory.

func WithIgnoredTags

func WithIgnoredTags(tags ...string) Option

WithIgnoredTags skips scenarios carrying any of the given tags.

func WithTags

func WithTags(tags ...string) Option

WithTags restricts execution to scenarios carrying any of the given tags.

type StepTest

type StepTest = gobdd.StepTest

StepTest is the interface for gobdd's step-level assertions.

type Suite

type Suite = gobdd.Suite

Suite is the type alias for gobdd's test suite.

func NewSuite

func NewSuite(t TestingT, opts ...Option) *Suite

NewSuite is a passthrough constructor for the on-disk case. Equivalent to gobdd.NewSuite but returns the hex-aliased type.

func NewSuiteFS

func NewSuiteFS(t TestingTB, f fs.FS, glob string, opts ...Option) *Suite

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.

type TestingT

type TestingT = gobdd.TestingT

TestingT is the *testing.T subset gobdd requires. hex re-exports it so consumers can accept it in their own helpers without importing gobdd.

type TestingTB

type TestingTB interface {
	TestingT
	Helper()
	TempDir() string
	Fatalf(format string, args ...any)
}

TestingTB is the subset of *testing.T that NewSuiteFS uses. Widened beyond gobdd.TestingT so we can call TempDir and Helper. Standard *testing.T satisfies it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL