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
edio opened this issue Jan 3, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@edio
Copy link

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

This comment has been minimized.

Copy link

commented Jan 3, 2018

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 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

This comment has been minimized.

Copy link
Member

commented Jan 3, 2018

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

@gopherbot gopherbot closed this in 43bf63f Jan 4, 2018

@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.
You can’t perform that action at this time.