-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
For larger Go projects, it's common to write some utility functions or types for use in it's test suite. Ideally, those utilities should themselves be tested. However, there are certain types of behaviour that are difficult to test at present:
- Check that a function causes a test to fail.
- Check that a function logs a particular message.
- Check that a function spawns an expected set of subtests.
With most testing frameworks, the usual method to handle this would be to invoke the test runner with a custom set of tests, and then inspect the results. That's not really possible with Go's testing framework, since the method of constructing a test suite and invoking the runner is all private API (either inaccessible like testing/internal/testdeps, or documented to be unstable like testing.TestMain). Also, the runner depends on global state through flags that would be shared with the real test suite.