Skip to content

proposal: testing: provide a way to more easily test test utility #42827

@jhenstridge

Description

@jhenstridge

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:

  1. Check that a function causes a test to fail.
  2. Check that a function logs a particular message.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions