aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChangkun Ou <hi@changkun.de>2021-07-26 15:04:48 +0200
committerIan Lance Taylor <iant@golang.org>2021-07-27 05:07:46 +0000
commit7ba8e796c91eaf4befcacc4d24127ae54475d6a5 (patch)
treef9ef03aeead1c9a5c0f07f6281e9e1b1de2f56e3 /src
parent33ff1559702388c57c45f9e6cd032f06e8c3c163 (diff)
downloadgo-7ba8e796c91eaf4befcacc4d24127ae54475d6a5.tar.gz
go-7ba8e796c91eaf4befcacc4d24127ae54475d6a5.zip
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 <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/testing/testing.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go
index 681f99ef93..a19238d31e 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -680,7 +680,11 @@ type T struct {
func (c *common) private() {}
-// Name returns the name of the running test or benchmark.
+// Name returns the name of the running (sub-) test or benchmark.
+//
+// The name will include the name of the test along with the names of
+// any nested sub-tests. If two sibling sub-tests have the same name,
+// Name will append a suffix to guarantee the returned name is unique.
func (c *common) Name() string {
return c.name
}