Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommonT ¶
type CommonT interface { Errorf(format string, args ...interface{}) FailNow() TempDir() string Cleanup(fn func()) Logf(format string, args ...any) Helper() Name() string Logger() log.Logger Ctx() context.Context Require() *require.Assertions }
CommonT is a subset of testing.T, extended with a few common utils. This interface should not be used directly. Instead, use T in test-scope, or P when operating at package level.
This CommonT interface is minimal enough such that it can be implemented by tooling, and a *testing.T can be used with minimal wrapping.
type P ¶
type P interface { CommonT // TempDir creates a temporary directory, and returns the file-path. // This directory is cleaned up at the end of the package, // and can be shared safely between tests that run in that package scope. TempDir() string // Cleanup runs the given function at the end of the package-scope. // This function will clean-up once the package-level testing is fully complete. // These resources can thus be shared safely between tests. Cleanup(fn func()) // Close closes the testing handle. This cancels the context and runs all cleanup. Close() // contains filtered or unexported methods }
P is used by the preset package and system backends as testing interface, to host package-wide resources.
type T ¶
type T interface { CommonT // TempDir creates a temporary directory, and returns the file-path. // This directory is cleaned up at the end of the test, and must not be shared between tests. TempDir() string // Cleanup runs the given function at the end of the test-scope, // or at the end of the sub-test (if this is a nested test). // This function will clean-up before the package-level testing scope may be complete. // Do not use the test-scope cleanup with shared resources. Cleanup(fn func()) // Run runs the given function in as a sub-test. Run(name string, fn func(T)) // Ctx returns a context that will be canceled at the end of this (sub) test-scope, // and inherits the context of the parent-test-scope. Ctx() context.Context // Parallel signals that this test is to be run in parallel with (and only with) other parallel tests. Parallel() Skip(args ...any) Skipped() bool Skipf(format string, args ...any) SkipNow() // contains filtered or unexported methods }
Click to show internal directories.
Click to hide internal directories.