Path: blob/main/vendor/github.com/sclevine/spec/README.md
2875 views
spec
Spec is a simple BDD test organizer for Go. It minimally extends the standard library testing package by facilitating easy organization of Go 1.7+ subtests.
Spec differs from other BDD libraries for Go in that it:
Does not reimplement or replace any functionality of the
testingpackageDoes not provide an alternative test parallelization strategy to the
testingpackageDoes not provide assertions
Does not encourage the use of dot-imports
Does not reuse any closures between test runs (to avoid test pollution)
Does not use global state, excessive interface types, or reflection
Spec is intended for gophers who want to write BDD tests in idiomatic Go using the standard library testing package. Spec aims to do "one thing right," and does not provide a wide DSL or any functionality outside of test organization.
Features
Clean, simple syntax
Supports focusing and pending tests
Supports sequential, random, reverse, and parallel test order
Provides granular control over test order and subtest nesting
Provides a test writer to manage test output
Provides a generic, asynchronous reporting interface
Provides multiple reporter implementations
Notes
Use
go test -vto see individual subtests.
Examples
Most functionality is demonstrated here.
Quick example:
With less nesting:
For focusing/reporting across multiple files in a package: