Closed cweill closed 8 years ago
+1 This is an amazing work you've done here. Thanks for spoon-feeding us lazy bums :)
@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?
@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:
--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.gotests
package tests output generated test files, and simply copying them to the testdata/
dir.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.
Sounds good! Looking forward to your PR.
@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/
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.
Subtests are introduced in Go 1.7. They'll be very useful for table driven tests.
See https://github.com/golang/go/issues/9268