func Run(t *testing.T, suite TestingSuite)
Run takes a testing suite and runs all of the tests attached to it.
AfterTest has a function to be executed right after the test finishes and receives the suite and test names as input
type AfterTest interface {
AfterTest(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 BeforeTest interface {
BeforeTest(suiteName, testName string)
}
SetupAllSuite has a SetupSuite method, which will run before the tests in the suite are run.
type SetupAllSuite interface {
SetupSuite()
}
SetupTestSuite has a SetupTest method, which will run before each test in the suite.
type SetupTestSuite interface {
SetupTest()
}
Suite is a basic testing suite with methods for storing and retrieving the current *testing.T context.
type Suite struct {
*assert.Assertions
// contains filtered or unexported fields
}
func (suite *Suite) Assert() *assert.Assertions
Assert returns an assert context for suite. Normally, you can call `suite.NoError(expected, actual)`, but for situations where the embedded methods are overridden (for example, you might want to override assert.Assertions with require.Assertions), this method is provided so you can call `suite.Assert().NoError()`.
func (suite *Suite) Require() *require.Assertions
Require returns a require context for suite.
func (suite *Suite) Run(name string, subtest func()) 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 *Suite) SetT(t *testing.T)
SetT sets the current *testing.T context.
func (suite *Suite) T() *testing.T
T retrieves the current *testing.T context.
TearDownAllSuite has a TearDownSuite method, which will run after all the tests in the suite have been run.
type TearDownAllSuite interface {
TearDownSuite()
}
TearDownTestSuite has a TearDownTest method, which will run after each test in the suite.
type TearDownTestSuite interface {
TearDownTest()
}
TestingSuite can store and return the current *testing.T context generated by 'go test'.
type TestingSuite interface {
T() *testing.T
SetT(*testing.T)
}