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

Underscores in Generated Tests #106

Open
taiidani opened this issue Aug 2, 2019 · 4 comments
Open

Underscores in Generated Tests #106

taiidani opened this issue Aug 2, 2019 · 4 comments
Assignees
Labels

Comments

@taiidani
Copy link

taiidani commented Aug 2, 2019

Our team is currently having a discussion over underscores being present in the generated Tests for gotests. These underscores appear to match the naming convention defined in https://golang.org/pkg/testing/#hdr-Examples but that convention implies that is for Examples only, not Tests.

Wondering what discussion occurred that led to this convention in gotests applying for the generated Tests? We'd love to know!

@cweill cweill self-assigned this Aug 14, 2019
@cweill
Copy link
Owner

cweill commented Aug 14, 2019

@taiidani: It was a solution to the fact that in Golang you can have a function called Foo and foo in the same package or on the same struct. So if you generated a test for both, they would have identical test names. The examples link shows an example of when you can have the underscores, but I agree that it's not the most aesthetically pleasing. :)

That being said, there was no formal discussion with the Go core team about this feature, and I would love to get other opinions.

@taiidani
Copy link
Author

Ah, thank you for the explanation! Yes the discussion on our side centered mainly around aesthetics. Not a big deal, but it cut a swath through our team on which each engineer preferred.

We've been using the test auto-generator built into VS Code's Golang extension to get quickly generated table tests. Some of the argument centered exactly around your explanation -- that in order to delineate between exported and unexported functions some extra symbol (the _) would be required. It makes sense, and I bet can lead to excellent IDE integrations like "Jump to Test for Function" / "Jump to Function for Test" actions. I'd hoped that the formatting decision was more baked into the Golang standards though in order to justify that feature :(

If you think it's worth additional discussion, perhaps I should create an equivalent issue in the main golang/go repository? Either way, thanks again for clarifying!

@cweill
Copy link
Owner

cweill commented Aug 16, 2019

@taiidani: I agree, it might be worth reaching out to the Golang team and getting their opinion.

@taiidani
Copy link
Author

@cweill Upgraded this to a proposal issue in golang/go: golang/go#33688

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants