-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
Comments
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. |
Change https://golang.org/cl/145279 mentions this issue: |
At least, now it is a bit mentioned. I may expand its documentation. |
**Description of the change:** - Update the go e2e test to have the suffix `_test` which has [special meaning for the Go compiler](golang/go#25223). - Cleanup the test in order to make all following the same standard - Ensure that the test are done using the makefile targets scaffolds as we suggest in our docs. - Add tests to ensure the metrics, run the project locally and the bundle sdk features - fix the target in the doc https://master.sdk.operatorframework.io/docs/olm-integration/generation/#package-manifests-format. Users should use `$(KUSTOMIZE)` instead of kustomize directly. - Fix Prometheus typo issue **Motivation for the change:** - maintainability, readability and reusability - ensure that our e2e tests are using the targets commands as we suggested to the users in the docs NOTE: The first goal is to keep all tests following the same standard. However, it still has a hall for improvements that ought to make horizontally in follow-ups.
hello @bcmills https://pkg.go.dev/testing now has an additional sentence:
it continues with:
Does that cover the intent of this issue? |
This comment was marked as outdated.
This comment was marked as outdated.
@marco-m No, that doesn't cover the intent of this issue. The documentation still only mentions the filename convention of adding This issue is about the difference between |
The existing documentation did not explain the difference between placing a _test.go file in the same package as what is being tested vs. adding it to a seprate _test package. This explains the distinction and adds an example. Concept is explained well here: https://stackoverflow.com/a/31443271 Fixes golang#25223
The existing documentation did not explain the difference between placing a _test.go file in the same package as what is being tested vs. adding it to a seprate _test package. This explains the distinction and adds an example. Concept is explained well here: https://stackoverflow.com/a/31443271 Fixes golang#25223
Change https://go.dev/cl/420415 mentions this issue: |
Change https://go.dev/cl/454335 mentions this issue: |
https://tip.golang.org/cmd/go/#hdr-Test_packages says:
However, https://tip.golang.org/pkg/testing/ omits that detail (emphasis mine):
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. Thetesting
package is an important entry point for users who are new to Go: its documentation should mention both package options or neither.The text was updated successfully, but these errors were encountered: