Help us shape the future of Go! Take the 2026 Go Developer Survey

gobdd

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2020 License: MIT Imports: 15 Imported by: 3

README

GOBDD

GoDoc Coverage Status

This is a BDD testing framework. Uses gherkin for the test's syntax. Project is under active development.

More detailed documentation can be found on the docs page: https://go-bdd.github.io/gobdd/

Contributing

All contributions are very much welcome. If you'd like to help with GoBDD development, please see open issues and submit your pull request via GitHub.

Support

If you didn't find the answer to your question in the documentation, feel free to ask us directly!

Please join us on the #go-bdd-library channel on the Gophers slack: You can get an invite here. You can find updates about the progress on Twitter: GoBdd.

You can support my work using issuehunt or by buying me a coffee.

Documentation

Overview

This project is created as the alternative to https://github.com/DATA-DOG/godog and is inspirited by it. There are a few differences between both solutions:

- GoBDD uses the built-in testing framework

- GoBDD is run as standard test case (not a separate program)

- you can use every Go native feature like build tags, pprof and so on

- the context in every test case contains all the required information to run (values passed from previous steps). More information can be found in the readme file https://github.com/go-bdd/gobdd/blob/master/README.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunInParallel added in v0.7.0

func RunInParallel() func(*SuiteOptions)

RunInParallel runs tests in parallel

func WithAfterScenario added in v0.7.0

func WithAfterScenario(f func(ctx context.Context)) func(*SuiteOptions)

WithAfterScenario configures functions that should be executed after every scenario

func WithBeforeScenario added in v0.7.0

func WithBeforeScenario(f func(ctx context.Context)) func(*SuiteOptions)

WithBeforeScenario configures functions that should be executed before every scenario

func WithFeaturesPath added in v0.7.0

func WithFeaturesPath(path string) func(*SuiteOptions)

WithFeaturesPath configures a pattern (regexp) where feature can be found. The default value is "features/*.feature"

func WithIgnoredTags added in v0.7.0

func WithIgnoredTags(tags []string) func(*SuiteOptions)

WithIgnoredTags configures which tags should be skipped while executing a suite Every tag has to start with @ otherwise will be ignored

func WithTags added in v0.7.0

func WithTags(tags []string) func(*SuiteOptions)

WithTags configures which tags should be skipped while executing a suite Every tag has to start with @

Types

type StepTest added in v0.7.0

type StepTest interface {
	Log(...interface{})
	Logf(string, ...interface{})
	Fatal(...interface{})
	Fatalf(string, ...interface{})
	Errorf(string, ...interface{})
	Error(...interface{})
}

type Suite

type Suite struct {
	// contains filtered or unexported fields
}

Holds all the information about the suite (options, steps to execute etc)

func NewSuite

func NewSuite(t TestingT, optionClosures ...func(*SuiteOptions)) *Suite

Creates a new suites with given configuration and empty steps defined

func (*Suite) AddRegexStep added in v0.6.0

func (s *Suite) AddRegexStep(expr *regexp.Regexp, step interface{})

AddRegexStep registers a step in the suite.

The second parameter is the step function that gets executed when a step definition matches the provided regular expression.

A step function can have any number of parameters (even zero), but it MUST accept a gobdd.StepTest and context.Context as the first parameters (if there is any) and MUST return the context.Context back:

func myStepFunction(t gobdd.StepTest, ctx context.Context, first int, second int) context.Context {
	return ctx
}

func (*Suite) AddStep

func (s *Suite) AddStep(expr string, step interface{})

AddStep registers a step in the suite.

The second parameter is the step function that gets executed when a step definition matches the provided regular expression.

A step function can have any number of parameters (even zero), but it MUST accept a gobdd.StepTest and context.Context as the first parameters (if there is any) and MUST return the context.Context back:

func myStepFunction(t gobdd.StepTest, ctx context.Context, first int, second int) context.Context {
	return ctx
}

func (*Suite) Run

func (s *Suite) Run()

Executes the suite with given options and defined steps

type SuiteOptions

type SuiteOptions struct {
	// contains filtered or unexported fields
}

Holds all the information about how the suite or features/steps should be configured

func NewSuiteOptions

func NewSuiteOptions() SuiteOptions

creates a new suite configuration with default values

type TestingT added in v0.6.0

type TestingT interface {
	StepTest
	Parallel()
	Fail()
	Run(name string, f func(t *testing.T)) bool
}

Directories

Path Synopsis
Code generated .* DO NOT EDIT.
Code generated .* DO NOT EDIT.

Jump to

Keyboard shortcuts

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