suite

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run[T any, G any](testingT *testing.T)

Run runs all of the tests attached to a suite.

Types

type AfterTest

type AfterTest interface {
	AfterTest(suiteName, testName string)
}

AfterTest has a function to be executed right after the test finishes and receives the suite and test names as input

type BeforeTest

type BeforeTest interface {
	BeforeTest(suiteName, testName string)
}

BeforeTest has a function to be executed right before the test starts and receives the suite and test names as input

type SetupAllSuite

type SetupAllSuite interface {
	SetupSuite()
}

SetupAllSuite has a SetupSuite method, which will run before the tests in the suite are run.

type SetupSubTest

type SetupSubTest interface {
	SetupSubTest()
}

SetupSubTest has a SetupSubTest method, which will run before each subtest in the suite.

type SetupTestSuite

type SetupTestSuite interface {
	SetupTest()
}

SetupTestSuite has a SetupTest method, which will run before each test in the suite.

type Suite

type Suite[T any, G any] struct {
	*assert.Assertions
	// contains filtered or unexported fields
}

func (*Suite[T, G]) Assert

func (s *Suite[T, G]) Assert() *assert.Assertions

Assert returns an assert context for suite.

func (*Suite[T, G]) Cleanup

func (s *Suite[T, G]) Cleanup(f func())

func (*Suite[T, G]) Deadline

func (s *Suite[T, G]) Deadline() (deadline time.Time, ok bool)

func (*Suite[T, G]) Failed

func (s *Suite[T, G]) Failed() bool

func (*Suite[T, G]) Fatal

func (s *Suite[T, G]) Fatal(args ...any)

func (*Suite[T, G]) Fatalf

func (s *Suite[T, G]) Fatalf(format string, args ...any)

func (*Suite[T, G]) G

func (s *Suite[T, G]) G() *G

G retrieves the global data for the suite.

func (*Suite[T, G]) Helper

func (s *Suite[T, G]) Helper()

func (*Suite[T, G]) Log

func (s *Suite[T, G]) Log(args ...any)

func (*Suite[T, G]) Logf

func (s *Suite[T, G]) Logf(format string, args ...any)

func (*Suite[T, G]) Name

func (s *Suite[T, G]) Name() string

func (*Suite[T, G]) Parallel

func (s *Suite[T, G]) Parallel()

func (*Suite[T, G]) Parent added in v0.3.0

func (s *Suite[T, G]) Parent() *T

func (*Suite[T, G]) Require

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

Require returns a require context for suite.

func (*Suite[T, G]) Run

func (s *Suite[T, G]) Run(name string, subtest func(suite *T)) bool

Run provides suite functionality around golang subtests. It should be called in place of t.Run(name, func(t *testing.T)) in test suite code. The passed-in func will be executed as a subtest with a fresh instance of t. Provides compatibility with go test pkg -run TestSuite/TestName/SubTestName.

func (*Suite[T, G]) Setenv

func (s *Suite[T, G]) Setenv(key, value string)

func (*Suite[T, G]) Skip

func (s *Suite[T, G]) Skip(args ...any)

func (*Suite[T, G]) SkipNow

func (s *Suite[T, G]) SkipNow()

func (*Suite[T, G]) Skipf

func (s *Suite[T, G]) Skipf(format string, args ...any)

func (*Suite[T, G]) Skipped

func (s *Suite[T, G]) Skipped() bool

func (*Suite[T, G]) T

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

T retrieves the current *testing.T context.

func (*Suite[T, G]) TempDir

func (s *Suite[T, G]) TempDir() string

type SuiteInformation

type SuiteInformation struct {
	Start, End time.Time
	TestStats  map[string]*TestInformation
}

SuiteInformation stats stores stats for the whole suite execution.

func (SuiteInformation) Passed

func (s SuiteInformation) Passed() bool

type TearDownAllSuite

type TearDownAllSuite interface {
	TearDownSuite()
}

TearDownAllSuite has a TearDownSuite method, which will run after all the tests in the suite have been run.

type TearDownSubTest

type TearDownSubTest interface {
	TearDownSubTest()
}

TearDownSubTest has a TearDownSubTest method, which will run after each subtest in the suite have been run.

type TearDownTestSuite

type TearDownTestSuite interface {
	TearDownTest()
}

TearDownTestSuite has a TearDownTest method, which will run after each test in the suite.

type TestInformation

type TestInformation struct {
	TestName   string
	Start, End time.Time
	Passed     bool
}

TestInformation stores information about the execution of each test.

type WithStats

type WithStats interface {
	HandleStats(suiteName string, stats *SuiteInformation)
}

WithStats implements HandleStats, a function that will be executed when a test suite is finished. The stats contain information about the execution of that suite and its tests.

Jump to

Keyboard shortcuts

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