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

Use subtests once Go 1.7 is released #23

Closed
cweill opened this issue Jul 28, 2016 · 7 comments
Closed

Use subtests once Go 1.7 is released #23

cweill opened this issue Jul 28, 2016 · 7 comments

Comments

@cweill
Copy link
Owner

cweill commented Jul 28, 2016

Subtests are introduced in Go 1.7. They'll be very useful for table driven tests.

See golang/go#9268

@iMaxopoly
Copy link

+1 This is an amazing work you've done here. Thanks for spoon-feeding us lazy bums :)

@itsjamie
Copy link
Contributor

itsjamie commented Oct 18, 2016

@cweill Is this something you would accept a PR for? I just started using the package in VSCode and would write this up soon if it isn't already being worked on.

I assume it should conditionally use the old template for 1.6, and use the subtests template for >=1.7?

@cweill
Copy link
Owner Author

cweill commented Oct 18, 2016

@itsjamie I would be open to PR if you are interested in taking this on. I know a lot of people who would really appreciate this feature, but I haven't had the time to work on this lately.

There would be three requirements:

  1. It should use the same templates to generate the subtests.
  2. To maintain backwards compatibility, we could conditionally check the go version, though I'm not sure how to do that exactly, and it may make the code more difficult to maintain. Alternatively, we can add a flag like --no_subtests, which allows users to disable the feature it if they don't like the format, or if they are using an older version of Go.
  3. Tests should be regenerated to use the subtests format. This is really easy to do by finding the tmp directory where the gotests package tests output generated test files, and simply copying them to the testdata/ dir.

@itsjamie
Copy link
Contributor

I've started to work on this.

The approach I'm taking is creating a new template for >= Go 1.7.

Then, maintain the backwards compatibility I'm using build tags, so for <Go 1.7, the template functions target the existing template, and for Go 1.7+ they target the new template.

I moved the template into two separate files just to see all the differences. If you would rather have it just use conditions in the same template, that can also be done. I'll put the PR up when I get access to my personal computer today so you can review and let me know what I need to fix.

@cweill
Copy link
Owner Author

cweill commented Oct 25, 2016

Sounds good! Looking forward to your PR.

@cweill
Copy link
Owner Author

cweill commented Nov 8, 2016

@itsjamie thanks again for your help! I posted on r/golang, and it seems like a lot of Gophers are excited to have this feature.

https://www.reddit.com/r/golang/comments/5bo6tp/gotests_test_generation_tool_now_supports/

@itsjamie
Copy link
Contributor

itsjamie commented Nov 8, 2016

Neat. Thanks for letting me. Now I can work on getting the behaviour and flag supported in vscode :) In case you didn't know they use your binary in the official vscode-go extension.

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

No branches or pull requests

3 participants