Skip to content

testing: unclear if T.Name includes sub-tests as part of its string #46488

Closed
@mvdan

Description

@mvdan

The current docs say:

Name returns the name of the running test or benchmark.

For a func TestFoo(t *testing.T), I think it's reasonably clear that Name will be TestFoo.

However, for a sub-test like t.Run("Bar", ...), it's not clear from the documentation if Name will return TestFoo/Bar or just TestFoo.

Another open question is whether the name will be altered, just like it is when printing output. For example, t.Run("bar baz", ...) ends up printing TestFoo/bar_baz in the terminal, so if the subtest name is included in the Name method, I'm not sure which of the two I'd expect.

cc @mpvl as per the owners doc
cc @adg @bradfitz since they added the Name method

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.help wanted

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions