Skip to content

Commit 7ba8e79

Browse files
changkunianlancetaylor
authored andcommitted
testing: clarify T.Name returns a distinct name of the running test
According to the discussion, it is clear that T.Name returns a distinct name among all tests. However, there is no specification of how sub-tests with the same specified test name are constructed. This change only clarifies the uniqueness and the components of the name without suggesting any explicit format of the returned name. Fixes #46488 Change-Id: I6cebd419b69fb08d8646cb744a129548452042ef Reviewed-on: https://go-review.googlesource.com/c/go/+/337392 Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Emmanuel Odeke <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent 33ff155 commit 7ba8e79

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/testing/testing.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,11 @@ type T struct {
680680

681681
func (c *common) private() {}
682682

683-
// Name returns the name of the running test or benchmark.
683+
// Name returns the name of the running (sub-) test or benchmark.
684+
//
685+
// The name will include the name of the test along with the names of
686+
// any nested sub-tests. If two sibling sub-tests have the same name,
687+
// Name will append a suffix to guarantee the returned name is unique.
684688
func (c *common) Name() string {
685689
return c.name
686690
}

0 commit comments

Comments
 (0)