Documentation ¶
Overview ¶
Package odize lightweight wrapper over the standard testing lib that enables some additional features such as tagging and test lifecycle hooks.
Index ¶
- Constants
- Variables
- func AssertEqual(t *testing.T, expected any, actual any)
- func AssertError(t *testing.T, err error)
- func AssertFalse(t *testing.T, value bool)
- func AssertNil(t *testing.T, value any)
- func AssertNoError(t *testing.T, err error)
- func AssertTrue(t *testing.T, value bool)
- type ErrorList
- type TestFn
- type TestFuncOpts
- type TestGroup
- type TestOpts
- type TestRegistryEntry
Constants ¶
const ( // ODIZE_TAGS is the environment variable that is used to filter tests ODIZE_TAGS = "ODIZE_TAGS" // ENV variable declared in pipelines such as Github Actions ENV_CI = "CI" )
Variables ¶
var (
ErrTestOptionNotAllowedInCI = fmt.Errorf("test option 'Only' not allowed in CI environment")
)
Functions ¶
func AssertFalse ¶ added in v1.0.1
AssertFalse checks if value is true
Example:
AssertFalse(t, methodReturnsFalse())
Types ¶
type ErrorList ¶
type ErrorList struct {
// contains filtered or unexported fields
}
ErrorList - keep track of a number of errors
type TestFuncOpts ¶ added in v1.1.1
type TestFuncOpts = func(*TestOpts)
func Only ¶ added in v1.1.1
func Only() TestFuncOpts
Only - Only run this test. If multiple tests are marked as only, the group will run only the tests marked as only
type TestGroup ¶
type TestGroup struct {
// contains filtered or unexported fields
}
TestGroup - Group tests together, contains lifecycle context.
func NewGroup ¶
NewGroup - Create a new test group.
If t he ODIZE_TAGS environment variable is set, then only tests with matching tags will be run.
func (*TestGroup) AfterAll ¶
func (tg *TestGroup) AfterAll(fn func())
AfterAll - Run after all tests
func (*TestGroup) AfterEach ¶
func (tg *TestGroup) AfterEach(fn func())
AfterEach - Run after each test
func (*TestGroup) BeforeAll ¶
func (tg *TestGroup) BeforeAll(fn func())
BeforeAll - Run before all tests
func (*TestGroup) BeforeEach ¶
func (tg *TestGroup) BeforeEach(fn func())
BeforeEach - Run before each test
type TestRegistryEntry ¶
type TestRegistryEntry struct {
// contains filtered or unexported fields
}
TestRegistryEntry - Test name and function to execute on run