mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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:
parent
f05c8b48ea
commit
43bf63fce1
3 changed files with 16 additions and 16 deletions
|
|
@ -1707,14 +1707,14 @@
|
||||||
// The 'go test' command expects to find test, benchmark, and example functions
|
// The 'go test' command expects to find test, benchmark, and example functions
|
||||||
// in the "*_test.go" files corresponding to the package under test.
|
// in the "*_test.go" files corresponding to the package under test.
|
||||||
//
|
//
|
||||||
// A test function is one named TestXXX (where XXX is any alphanumeric string
|
// A test function is one named TestXxx (where Xxx does not start with a
|
||||||
// not starting with a lower case letter) and should have the signature,
|
// 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
|
// 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.
|
// *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
|
// comment is compiled but not executed. An example with no text after
|
||||||
// "Output:" is compiled, executed, and expected to produce no output.
|
// "Output:" is compiled, executed, and expected to produce no output.
|
||||||
//
|
//
|
||||||
// Godoc displays the body of ExampleXXX to demonstrate the use
|
// Godoc displays the body of ExampleXxx to demonstrate the use
|
||||||
// of the function, constant, or variable XXX. An example of a method M with
|
// 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
|
// 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,
|
// for a given function, constant, or variable, distinguished by a trailing _xxx,
|
||||||
// where xxx is a suffix not beginning with an upper case letter.
|
// where xxx is a suffix not beginning with an upper case letter.
|
||||||
|
|
|
||||||
|
|
@ -406,14 +406,14 @@ var HelpTestfunc = &base.Command{
|
||||||
The 'go test' command expects to find test, benchmark, and example functions
|
The 'go test' command expects to find test, benchmark, and example functions
|
||||||
in the "*_test.go" files corresponding to the package under test.
|
in the "*_test.go" files corresponding to the package under test.
|
||||||
|
|
||||||
A test function is one named TestXXX (where XXX is any alphanumeric string
|
A test function is one named TestXxx (where Xxx does not start with a
|
||||||
not starting with a lower case letter) and should have the signature,
|
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
|
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.
|
*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
|
comment is compiled but not executed. An example with no text after
|
||||||
"Output:" is compiled, executed, and expected to produce no output.
|
"Output:" is compiled, executed, and expected to produce no output.
|
||||||
|
|
||||||
Godoc displays the body of ExampleXXX to demonstrate the use
|
Godoc displays the body of ExampleXxx to demonstrate the use
|
||||||
of the function, constant, or variable XXX. An example of a method M with
|
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
|
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,
|
for a given function, constant, or variable, distinguished by a trailing _xxx,
|
||||||
where xxx is a suffix not beginning with an upper case letter.
|
where xxx is a suffix not beginning with an upper case letter.
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
// It is intended to be used in concert with the ``go test'' command, which automates
|
// It is intended to be used in concert with the ``go test'' command, which automates
|
||||||
// execution of any function of the form
|
// execution of any function of the form
|
||||||
// func TestXxx(*testing.T)
|
// func TestXxx(*testing.T)
|
||||||
// where Xxx can be any alphanumeric string (but the first letter must not be in
|
// where Xxx does not start with a lowercase letter. The function name
|
||||||
// [a-z]) and serves to identify the test routine.
|
// serves to identify the test routine.
|
||||||
//
|
//
|
||||||
// Within these functions, use the Error, Fail or related methods to signal failure.
|
// Within these functions, use the Error, Fail or related methods to signal failure.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue