parallelsuite

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run[T testingSuite](t *testing.T, s T, args ...any)

Run discovers and runs all exported Test* methods on the given suite in parallel.

Each method gets its own fresh suite instance initialized for the subtest's *testing.T. Both the suite-level test and each method subtest are marked as parallel. Any sequential setup must happen before calling Run.

The suite must embed Suite and have no other fields.

func RunLegacySequential deprecated

func RunLegacySequential[T testingSuite](t *testing.T, s T, args ...any)

RunLegacySequential behaves like Run but does not mark test methods as parallel.

Deprecated: use Run for new tests. This only exists for backwards-compatibility with legacy behavior to ease migration.

Types

type Scope

type Scope interface {
	Context() context.Context
	TB() testing.TB
	Require() *require.Assertions
	AssertionT() require.TestingT
}

Scope provides the context and test handles for a test or await attempt. It is useful for test helpers.

func WithContext

func WithContext(ctx context.Context, scope Scope) Scope

WithContext returns a scope that uses ctx and delegates assertions to scope.

type Suite

type Suite[T testingSuite] struct {
	*require.Assertions
	protorequire.ProtoAssertions
	historyrequire.HistoryRequire
	// contains filtered or unexported fields
}

Suite provides parallel test execution with require-style (fail-fast) assertions.

It enforces a strict rule: a test method (or subtest) must either use assertions directly OR create subtests via Run — not both.

func (*Suite) Assert deprecated

func (b *Suite) Assert() *assert.Assertions

Deprecated: Assert returns non-fatal assertions which are not supported. Use s.NoError, s.Equal, etc. directly (require semantics).

func (*Suite[T]) AssertionT

func (s *Suite[T]) AssertionT() require.TestingT

AssertionT returns the active assertion target.

func (*Suite[T]) Await

func (s *Suite[T]) Await(fn func(T), timeout, interval time.Duration)

Await calls fn repeatedly until all assertions pass or timeout is reached.

func (*Suite[T]) AwaitTrue

func (s *Suite[T]) AwaitTrue(fn func() bool, timeout, interval time.Duration)

AwaitTrue calls fn repeatedly until it returns true or timeout is reached.

Use it for simple local predicates only. Do not use assertions or side effects; use [Await] instead.

func (*Suite[T]) AwaitTruef

func (s *Suite[T]) AwaitTruef(fn func() bool, timeout, interval time.Duration, msg string, args ...any)

AwaitTruef is like [AwaitTrue] but includes a format string appended to the failure message.

func (*Suite[T]) Awaitf

func (s *Suite[T]) Awaitf(fn func(T), timeout, interval time.Duration, msg string, args ...any)

Awaitf is like [Await] but includes a format string appended to the failure message.

func (*Suite[T]) Context

func (s *Suite[T]) Context() context.Context

Context returns the test-scoped context (created from testcontext). Inside an [Await] callback, it returns the await-scoped context.

func (*Suite[T]) Require

func (s *Suite[T]) Require() *require.Assertions

Require returns assertions bound to the active test or await attempt.

func (*Suite[T]) Run

func (s *Suite[T]) Run(name string, fn func(T)) bool

Run creates a parallel subtest. The callback receives a fresh copy of the concrete suite type, initialized for the subtest's *testing.T.

func (*Suite) SetS deprecated

func (b *Suite) SetS(_ testifysuite.TestingSuite)

Deprecated: SetS is managed internally by Run. Do not call directly.

func (*Suite) SetT deprecated

func (b *Suite) SetT(_ *testing.T)

Deprecated: SetT is managed internally by Run. Do not call directly.

func (*Suite[T]) T

func (s *Suite[T]) T() *testing.T

T returns the *testing.T, panicking if the guard has been sealed.

func (*Suite[T]) TB

func (s *Suite[T]) TB() testing.TB

TB returns the underlying test handle.

Jump to

Keyboard shortcuts

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