Documentation ¶
Index ¶
- func Focus(t *testing.T, text string, f func(*testing.T, G, S), opts ...Option) bool
- func Pend(t *testing.T, text string, f func(*testing.T, G, S), _ ...Option) bool
- func Run(t *testing.T, text string, f func(*testing.T, G, S), opts ...Option) bool
- type G
- type Option
- type Plan
- type Reporter
- type S
- type Spec
- type Suite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Focus ¶
Focus focuses every spec in the provided suite. This is useful as a shortcut for unfocusing all focused specs.
Valid Options: Sequential, Random, Reverse, Parallel Local, Global, Flat, Nested Seed, Report
Types ¶
type G ¶
G defines a group of specs. Unlike other testing libraries, it is re-evaluated for each subspec.
Valid Options: Sequential, Random, Reverse, Parallel Local, Global, Flat, Nested
type Option ¶
type Option func(*config)
An Option controls the behavior of a suite, group, or spec. Options are inherited by subgroups and subspecs.
Example: If the top-level Run group is specified as Random(), each subgroup will inherit the Random() order. This means that each group will be randomized individually, unless another ordering is specified on any of the subgroups. If the Run group is also passed Global(), then all specs inside Run will run in completely random order, regardless of any ordering specified on the subgroups.
func Flat ¶
func Flat() Option
Flat indicates that a parent subtest should not be created for the group. This is the default behavior.
Valid Option for: New, Run, Focus, Pend, Suite, Suite.Focus, Suite.Pend, G, G.Focus, G.Pend
func Global ¶
func Global() Option
Global indicates that test order applies globally to all descendant specs. For example, a group with Random() and Global() will run all descendant specs in random order, regardless of subgroup. Specs in different subgroups may be interleaved.
Valid Option for: New, Run, Focus, Pend, Suite, Suite.Focus, Suite.Pend, G, G.Focus, G.Pend
func Local ¶
func Local() Option
Local indicates that the test order applies to each subgroup individually. For example, a group with Random() and Local() will run all subgroups and specs in random order, and each subgroup will be randomized, but specs in different subgroups will not be interleaved. This is the default behavior.
Valid Option for: New, Run, Focus, Pend, Suite, Suite.Focus, Suite.Pend, G, G.Focus, G.Pend
func Nested ¶
func Nested() Option
Nested indicates that a parent subtest should be created for the group. This allows for more control over parallelism.
Valid Option for: New, Run, Focus, Pend, Suite, Suite.Focus, Suite.Pend, G, G.Focus, G.Pend
func Parallel ¶
func Parallel() Option
Parallel indicates that a spec or group of specs should be run in parallel. This Option is equivalent to t.Parallel().
Valid Option for: New, Run, Focus, Pend, Suite, Suite.Focus, Suite.Pend, G, G.Focus, G.Pend, S
func Random ¶
func Random() Option
Random indicates that a group of specs should be run in random order. Randomization is per group, such that all groupings are maintained.
Valid Option for: New, Run, Focus, Pend, Suite, Suite.Focus, Suite.Pend, G, G.Focus, G.Pend
func Reverse ¶
func Reverse() Option
Reverse indicates that a group of specs should be run in reverse order.
Valid Option for: New, Run, Focus, Pend, Suite, Suite.Focus, Suite.Pend, G, G.Focus, G.Pend
func Seed ¶
Seed specifies the random seed used for any randomized specs in a Run block. The random seed is always displayed before specs are run. If not specified, the current time is used.
Valid Option for: New, Run, Focus, Pend
func Sequential ¶
func Sequential() Option
Sequential indicates that a group of specs should be run in order. This is the default behavior.
Valid Option for: New, Run, Focus, Pend, Suite, Suite.Focus, Suite.Pend, G, G.Focus, G.Pend
type Plan ¶
type Plan struct { Text string Total int Pending int Focused int Seed int64 HasRandom bool HasFocus bool }
A Plan provides a Reporter with information about a suite.
type Reporter ¶
type Reporter interface { // Start provides the Reporter with a Plan that describes the suite. // No specs will run until the Start method call finishes. Start(*testing.T, Plan) // Specs provides the Reporter with a channel of Specs. // The specs will start running concurrently with the Specs method call. // The Run method will not complete until the Specs method call completes. Specs(*testing.T, <-chan Spec) }
A Reporter is provided with information about a suite as it runs.
type S ¶
S defines a spec.
Valid Options: Parallel
func (S) Focus ¶
Focus focuses the provided spec. This skips all specs in the suite except the spec and other focused specs.
Valid Options: Parallel
type Spec ¶
type Spec struct { Text []string Failed bool Skipped bool Focused bool Parallel bool Out io.Reader }
A Spec provides a Reporter with information about a spec immediately after the spec completes.
type Suite ¶ added in v1.1.0
Suite defines a top-level group of specs within a suite. Suite behaves like a top-level version of G. Unlike other testing libraries, it is re-evaluated for each subspec.
Valid Options: Sequential, Random, Reverse, Parallel Local, Global, Flat, Nested
func New ¶ added in v1.1.0
New creates an empty suite and returns an Suite function. The Suite function may be called to add top-level groups to the suite. The suite may be executed with Suite.Run.
Valid Options: Sequential, Random, Reverse, Parallel Local, Global, Flat, Nested Seed, Report
func (Suite) Focus ¶ added in v1.1.0
Focus focuses the provided top-level group. This skips all specs in the suite except the group and other focused specs.
Valid Options: Sequential, Random, Reverse, Parallel Local, Global, Flat, Nested