Skip to content

proposal: testing: export test/benchmark name #16901

@RaduBerinde

Description

@RaduBerinde

This is a proposal to add a Name() string function to testing.TB that returns the name of the test/benchmark. This is necessary to differentiate between debugging messages, events, traces etc when running tests/benchmarks in parallel.

In many cases one can figure out the enclosing Test.. function by studying the caller stack but that wouldn't work for subtests. This feature would be especially useful when the subtests are generated programatically, e.g. for i := 1; i <= 5; i++ { t.Run(fmt.Sprintf("i=%d", i), ..)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions