1
0
mirror of https://github.com/golang/go synced 2024-11-19 15:54:46 -07:00

cmd/go, testing: test names don't have to be alphanumeric

In func TestXxxx(*testing.T) the Xxxx can be anything that can appear
in an identifier, but can't start with a lowercase letter. Clarify the docs.

Fixes #23322

Change-Id: I5c297916981f7e3890ee955d12bc7422a75488e2
Reviewed-on: https://go-review.googlesource.com/86001
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Ian Lance Taylor 2018-01-03 11:27:26 -08:00
parent f05c8b48ea
commit 43bf63fce1
3 changed files with 16 additions and 16 deletions

View File

@ -1707,14 +1707,14 @@
// The 'go test' command expects to find test, benchmark, and example functions
// in the "*_test.go" files corresponding to the package under test.
//
// A test function is one named TestXXX (where XXX is any alphanumeric string
// not starting with a lower case letter) and should have the signature,
// A test function is one named TestXxx (where Xxx does not start with a
// lower case letter) and should have the signature,
//
// func TestXXX(t *testing.T) { ... }
// func TestXxx(t *testing.T) { ... }
//
// A benchmark function is one named BenchmarkXXX and should have the signature,
// A benchmark function is one named BenchmarkXxx and should have the signature,
//
// func BenchmarkXXX(b *testing.B) { ... }
// func BenchmarkXxx(b *testing.B) { ... }
//
// An example function is similar to a test function but, instead of using
// *testing.T to report success or failure, prints output to os.Stdout.
@ -1725,8 +1725,8 @@
// comment is compiled but not executed. An example with no text after
// "Output:" is compiled, executed, and expected to produce no output.
//
// Godoc displays the body of ExampleXXX to demonstrate the use
// of the function, constant, or variable XXX. An example of a method M with
// Godoc displays the body of ExampleXxx to demonstrate the use
// of the function, constant, or variable Xxx. An example of a method M with
// receiver type T or *T is named ExampleT_M. There may be multiple examples
// for a given function, constant, or variable, distinguished by a trailing _xxx,
// where xxx is a suffix not beginning with an upper case letter.

View File

@ -406,14 +406,14 @@ var HelpTestfunc = &base.Command{
The 'go test' command expects to find test, benchmark, and example functions
in the "*_test.go" files corresponding to the package under test.
A test function is one named TestXXX (where XXX is any alphanumeric string
not starting with a lower case letter) and should have the signature,
A test function is one named TestXxx (where Xxx does not start with a
lower case letter) and should have the signature,
func TestXXX(t *testing.T) { ... }
func TestXxx(t *testing.T) { ... }
A benchmark function is one named BenchmarkXXX and should have the signature,
A benchmark function is one named BenchmarkXxx and should have the signature,
func BenchmarkXXX(b *testing.B) { ... }
func BenchmarkXxx(b *testing.B) { ... }
An example function is similar to a test function but, instead of using
*testing.T to report success or failure, prints output to os.Stdout.
@ -424,8 +424,8 @@ comment, however the order of the lines is ignored. An example with no such
comment is compiled but not executed. An example with no text after
"Output:" is compiled, executed, and expected to produce no output.
Godoc displays the body of ExampleXXX to demonstrate the use
of the function, constant, or variable XXX. An example of a method M with
Godoc displays the body of ExampleXxx to demonstrate the use
of the function, constant, or variable Xxx. An example of a method M with
receiver type T or *T is named ExampleT_M. There may be multiple examples
for a given function, constant, or variable, distinguished by a trailing _xxx,
where xxx is a suffix not beginning with an upper case letter.

View File

@ -6,8 +6,8 @@
// It is intended to be used in concert with the ``go test'' command, which automates
// execution of any function of the form
// func TestXxx(*testing.T)
// where Xxx can be any alphanumeric string (but the first letter must not be in
// [a-z]) and serves to identify the test routine.
// where Xxx does not start with a lowercase letter. The function name
// serves to identify the test routine.
//
// Within these functions, use the Error, Fail or related methods to signal failure.
//