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

Open
bcmills opened this issue May 2, 2018 · 3 comments
Open

testing: mention the “_test” package idiom #25223

bcmills opened this issue May 2, 2018 · 3 comments

Comments

@bcmills
Copy link
Member

@bcmills bcmills commented May 2, 2018

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.

@bcmills bcmills added this to the Unplanned milestone May 2, 2018
@rillig
Copy link
Contributor

@rillig rillig 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.

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 28, 2018

Change https://golang.org/cl/145279 mentions this issue: testing: mention the "_test" package idiom

@hearot
Copy link
Contributor

@hearot hearot commented Oct 28, 2018

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

@ALTree ALTree added the NeedsFix label Feb 3, 2020
camilamacedo86 added a commit to operator-framework/operator-sdk that referenced this issue Sep 15, 2020
**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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants