bdd

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2021 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package bdd defines a BDD-style bifurcated evaluation context, compatible with the build-in testing package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Given

func Given(t *testing.T, name string, f func(t *T)) bool

Given adds syntactic sugar on top of `bdd.Wrap()` and prefixes the name of the section with 'Given ...'.

func Wrap

func Wrap(t *testing.T, name string, f func(t *T)) bool

Wrap is the root function that wraps the top level testing.T context and starts a bifurcated bdd.T evaluation context.

Types

type T

type T struct {
	TB
	// contains filtered or unexported fields
}

T is a testing context, similar to testing.T, passed to the testing functions in the BDD style bifurcated test evaluation. It forwards most of the testing.T API by encapsulating the current test context as a `TB` interface; only `Parallel()` is dropped as non-relevant.

The `Run()` function has a similar interface as testing.T, but passing a bdd.T object for the nested testing context, and evaluating all branches in a BDD style bifurcated fashion, where each branch is fully and independently re-evaluated for every leaf.

Additional functions `When()` and `Then()` are syntactic sugar on top the `Run()` function. `bdd.Given()` is the root function that initializes the bifurcated evaluation context and runs all the branches.

func (*T) Run

func (b *T) Run(name string, f func(t *T)) bool

Run defines a new fork in the current bifurcated evaluation context.

func (*T) Then

func (b *T) Then(name string, f func(t *T)) bool

Then adds syntactic sugar on top of `bdd.T.Run()` and prefixes the name of the section with 'then ...'.

func (*T) When

func (b *T) When(name string, f func(t *T)) bool

When adds syntactic sugar on top of `bdd.T.Run()` and prefixes the name of the section with 'when ...'.

type TB

type TB interface {
	testing.TB
	Deadline() (deadline time.Time, ok bool)
}

TB is an interface definition that exposes all the `testing.T` functions that are not redefined by `bdd.T`.

Jump to

Keyboard shortcuts

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