Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Extra ¶
func Extra(pointersAndInjectors ...interface{}) nject.Provider
Extra is a means to obtain more than one of something needed for a test.
The extra bits may be need to be created in the middle of a pre-made injection sequence. The easiest way to handle that is to use nject.Provide() to name the injectors in the injection chain. Then you can use nject.InsertAfterNamed() to wrap the Extra() to "move" the effective location of the Extra.
Alternatively, you can avoid the pre-made injection sequences so that you explicitly add Extra in the middle.
The arguments to Extra can be two different kinds of things. First put pointers to variables that you want extra of. Then put any additional injectors that might be needed to create those things. You can nest calls to Extra inside call to Extra if you want to share some comment components.
func RunMatrix ¶
RunMatrix uses t.Run() separate execution for each sub-test before any chains are evaluated. This forces the chains to share nothing between them. RunMatrix does not provide any default injectors other than a *testing.T that comes from a named provider (named "testing.T")
A matrix is a specific type: map[string]nject.Provider. Add those to the chain to trigger matrix testing.
Matrix values must be direct arguments to RunMatrix -- they will not be extracted from nject.Sequences. RunMatrix will fail if there is no matrix provided.
func RunParallelMatrix ¶
RunParallelMatrix uses t.Run() to fork into multiple threads of execution for each sub-test before any chains are evaluated. This forces the chains to share nothing between them. RunParallelMatrix does not provide any default injectors other than a *testing.T that comes from a named provider (named "testing.T")
A matrix is a specific type: map[string]nject.Provider. Add those to the chain to trigger matrix testing.
t.Parallel() is used for each t.Run()
A warning about t.Parallel(): inner tests wait until outer tests finish. See https://go.dev/play/p/ZDaw054HeIN
Matrix values must be direct arguments to RunMatrix -- they will not be extracted from nject.Sequences. RunParallelMatrix will fail if there is no matrix provided.
Types ¶
type Cancel ¶ added in v0.4.0
type Cancel func()
Cancel is the injected type for the function type that will cancel a Context that has been augmented with AutoCancel.
type T ¶
type T interface { Cleanup(func()) Setenv(key, value string) Error(args ...interface{}) Errorf(format string, args ...interface{}) FailNow() Failed() bool Fatal(args ...interface{}) Fatalf(format string, args ...interface{}) Helper() Log(args ...interface{}) Logf(format string, args ...interface{}) Name() string Skip(args ...interface{}) Skipf(format string, args ...interface{}) Skipped() bool }
T is subset of what testing.T provides and is also a subset of of what ginkgo.GinkgoT() provides. This interface is probably richer than strictly required so more could be removed from it (or more added).
func BufferedLogger ¶ added in v0.6.0
BufferedLogger creates a T that buffers all log output and only outputs it during test cleanup if the test failed. Each log entry includes the filename and line number where the log was called. The purpose of this is for situations where go tests are defaulting to -v but output should be supressed anyway.
If the environment variable NTEST_BUFFERING is set to "false", buffering will be turned off.
func ExtraDetailLogger ¶ added in v0.3.0
ExtraDetailLogger creates a T that wraps the logger to add both a prefix and a timestamp to each line that is logged.
func ReplaceLogger ¶ added in v0.3.0
ReplaceLogger creates a T that is wrapped so that the logger is overridden with the provided function.