-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
https://tip.golang.org/cmd/go/#hdr-Test_packages 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, https://tip.golang.org/pkg/testing/ 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.