Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: test naming guidelines are inconsistent with real-world practice #23322

Closed
koiuo opened this issue Jan 3, 2018 · 2 comments
Closed
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@koiuo
Copy link

koiuo commented Jan 3, 2018

What version of Go are you using (go version)?

1.9.2

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

linux amd64

What did you do?

$ cat << EOF > foo_test.go
package foo
import "testing"

func Test_Foo(t *testing.T) {
    println("hello")
}
EOF
$ go test -v ./

What did you expect to see?

ok      _/some/dir     0.001s [no tests to run]

What did you see instead?

=== RUN   Test_Foo
hello
--- PASS: Test_Foo (0.00s)
PASS
ok      _/some/dir     0.002s

Official documentation for Go testing package states, that go test

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.

There are tons of open-source go projects that use _ (underscore) in tests names (although all Google projects I've seen so far do follow these naming guidelines), yet _ is not alphanumeric and, according to the documentation, should not work.

I believe either this statement in documentation has to be clarified or go test behavior has to be adjusted to conform to the documentation (unlikely, considering how ubiquitous _ became)

@gopherbot
Copy link

Change https://golang.org/cl/86001 mentions this issue: cmd/go, testing: test names don't have to be alphanumeric

@bradfitz bradfitz added this to the Go1.11 milestone Jan 3, 2018
@bradfitz bradfitz added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 3, 2018
@bradfitz bradfitz changed the title test naming guidelines are inconsistent with real-world practice testing: test naming guidelines are inconsistent with real-world practice Jan 3, 2018
@bradfitz
Copy link
Contributor

bradfitz commented Jan 3, 2018

I think underscore is generally regarded as being alphanumeric, but I suppose this could be clarified.

@golang golang locked and limited conversation to collaborators Jan 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants