vscode-go
vscode-go copied to clipboard
Add lenses for ginkgo to run specific tests
If you have a question, please ask it on the #vscode
or #vscode-go
channels in Gophers Slack](https://invite.slack.golangbridge.org/messages/vscode).
Is your feature request related to a problem? Please describe.
Ginkgo is a widely used BDD testing framework, which is used to describe individual specs. Ginkgo also offers cli options that are added when you run go test
which can be leveraged for lenses.
Describe the solution you'd like Today, vscode offers a way to run individual go tests as shown in the picture below.
It'd be great to have the same functionality on each ginkgo-spec using its name as input to ginkgo.focus
flag when running the go test
command.
Describe alternatives you've considered The only other way to run ginkgo individual tests today is to run the tests from the command line.
Additional context Happy to help with coding a solution up given enough guidance.
There is a similar feature request to support gocheck
.
https://github.com/golang/vscode-go/issues/111
Also, support for testify
landed in https://github.com/microsoft/vscode-go/pull/1707.
How many of test frameworks do we want this extension to support? How can we keep the extension up-to-date with all the changes in the test frameworks?
I wonder if we can come up with another way - For example, make the Go extension export an api for code analysis (e.g., proxying symbol lookup requests), so other extensions can retrieve information necessary to implement their own codelenses.
cc @stamblerre @ramya-rao-a
If there are more and more test frameworks to contend with, then I would recommend separate extensions for these.
What is required for codelens for any test framework is
- ability to get list of all functions in the file, with name, function signature and position in the file
- determine which of these functions need to get a codelens
- run the appropriate test command with the right input
- parse the output to convert relative links to absolute links so that failed tests with pointers to code are clickable in the test output
The first step is doable by shelling out to tools like go-outline
. The symbol provider in the Go extension can be used as reference.
The second and third step is specific to the framework being used.
The last step is optional. If needed, one can refer the parsing logic used in the Go extension.
Thank you all for the context. It seems like the best path forward is definitely to have a separate extension that can work together with vscode-go. Initially, I opted to open a new issue here given that testify is supported alongside normal go tests.
Ginkgo is used extensively in the Kubernetes community, I figure I'd bring this up and gather information and see how to proceed.