Skip to content

proposal: testing: programmatic sub-test and sub-benchmark support #12166

Description

@mpvl

Support for table-driven tests and benchmarks could be improved by allowing subtests and subbenchmarks to be spawned programmatically by allowing, for example, a Run method on T and B in the testing package. This would enable various use cases, such as:

  • an easy way to single out tests and benchmarks in a table from the command line (e.g. for debugging),
  • simplify writing a collection of similar benchmarks,
  • use of Fatal in sub tests without halting sibling subtests,
  • eliminate need to prefix each error message in a test with its subtest name, resulting in more consistent and simpler to write error messages,
  • creating subtests from an external/dynamic table source,
  • more control over scope of setup and teardown (more than TestMain allows now), and
  • more control over parallelism.

Semantically, subtests and subbenchmarks would behave exactly the same as the current top-level counterparts. In fact, the top-level counterparts could be implemented as subtests/benchmarks of a single root. Details would need to be worked out in a design doc.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions