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: mention the “_test” package idiom #25223

bcmills opened this issue May 2, 2018 · 3 comments


None yet
4 participants
Copy link

commented May 2, 2018 says:

Test files that declare a package with the suffix "_test" will be compiled as a separate package, and then linked and run with the main test binary.

However, omits that detail (emphasis mine):

To write a new test suite, create a file whose name ends _test.go that contains the TestXxx functions as described here. Put the file in the same package as the one being tested.

Tests in a separate _test package provide more realistic examples (and are better for catching awkward package names), so it's important that users be aware of that option. The testing package is an important entry point for users who are new to Go: its documentation should mention both package options or neither.

@bcmills bcmills added this to the Unplanned milestone May 2, 2018


This comment has been minimized.

Copy link

commented Oct 27, 2018

After programming in Go for three years, I learned about this feature in this Stack Overflow answer. If the one sentence mentioning white-box and black-box testing had been in the reference documentation or the Effective Go document, it would have helped me quite a bit.


This comment has been minimized.

Copy link

commented Oct 28, 2018

Change mentions this issue: testing: mention the "_test" package idiom


This comment has been minimized.

Copy link

commented Oct 28, 2018

At least, now it is a bit mentioned. I may expand its documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.