Skip to content

proposal: testing: provide TestMain with stats so that it can print a custom summary. #41878

@michael-schaller

Description

@michael-schaller

Background

There have been several requests in the past for a summary in the end of a test suite run:

All these requests have been denied as it isn't clear which summary style/format would clearly be beneficial.

The proposed workaround was to run the tests with -json and to use the output to generate a suitable summary.
For instance gotestsum provides just that but it is an external tool and so developers and automation need to diverge from their usual workflow in order to utilize gotestsum.

Proposal

Add test stats to testing.M so that TestMain can print a custom test results summary after m.Run().

The test stats should include:

  • List of all tests.
  • List of all examples.
  • List of all benchmarks.
  • List of successful tests.
  • List of successful examples.
  • List of successful benchmarks.
  • List of skipped tests.
  • List of skipped examples (in case of -failfast).
  • List of skipped benchmarks (in case tests or examples failed).
  • List of failed tests.
  • List of failed examples.
  • List of failed benchmarks.

This could be done by enhancing the runTests, runExamples and runBenchmarks functions to produce these lists.
All lists would be of type []InternalTest, []InternalExample or []InternalBenchmark.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions