bdd

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build[T any](build func(v *T)) *T

func Cases

func Cases[C any](cases ...C) iter.Seq[C]

func Given

func Given(setup func(T)) func(t *testing.T)

Types

type Checker

type Checker interface {
	Check(t TB)
}

func AsChecker

func AsChecker[T any](matcher internal.Matcher[T], actual T) Checker

func AsNegativeChecker

func AsNegativeChecker[T any](matcher internal.Matcher[T], actual T) Checker

func Be

func Be[A any](expect, actual A) Checker

func BeAssignableTo

func BeAssignableTo[E any](actual any) Checker

func BeConvertibleTo

func BeConvertibleTo[E any](actual any) Checker

func BeFalse

func BeFalse(a bool) Checker

func BeNil

func BeNil[A any](a A) Checker

func BeTrue

func BeTrue(a bool) Checker

func BeType

func BeType[E any](actual any) Checker

func Contains

func Contains[E comparable, S ~[]E](s S, v E) Checker

func ContainsSubString

func ContainsSubString(s, sub string) Checker

func Equal

func Equal[A any](expect, actual A) Checker

func EquivalentSlice

func EquivalentSlice[E comparable, S ~[]E](expect, actual S) Checker

func ErrorContains

func ErrorContains(sub string, err error) Checker

func ErrorEqual

func ErrorEqual(expect string, actual error) Checker

func Failed

func Failed(err error) Checker

func HaveCap

func HaveCap[A any](a A, cap int) Checker

func HaveLen

func HaveLen[A any](a A, len int) Checker

func HavePrefix

func HavePrefix(s, prefix string) Checker

func HaveSuffix

func HaveSuffix(s, suffix string) Checker

func IsCodeError

func IsCodeError[Code codex.Code](expect Code, actual error) Checker

func IsError

func IsError(expect, actual error) Checker

func IsNotZero

func IsNotZero[A any](expect A) Checker

func IsZero

func IsZero[A any](expect A) Checker

func NegativeChecker

func NegativeChecker[T any](c Checker) Checker

func NotBe

func NotBe[A any](expect, actual A) Checker

func NotBeNil

func NotBeNil[A any](a A) Checker

func NotEqual

func NotEqual[A any](expect, actual A) Checker

func Succeed

func Succeed(err error) Checker

type T

type T interface {
	TB

	Given(summary string, do func(b T))
	When(summary string, do func(b T))
	Then(summary string, checkers ...Checker)
}

T defines a Behavior Driver Development testing. It provides a domain-specific language (DSL) that is close to natural language, making test structures read like:

bdd.From(t).Given("Precondition", func(b bdd.T) {
	// setup precondition
	b.When("SomeAction", func(b bdd.T) {
		// do action
		b.Then("Expects", bdd.Equal("1", v))
	})
})

func From

func From(t *testing.T) T

type TB

type TB interface {
	Chdir(dir string)
	Setenv(key, value string)

	Skip(args ...any)
	Skipped() bool

	Context() context.Context
}

Jump to

Keyboard shortcuts

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