Description
Is your feature request related to a problem? Please describe.
I like to debug tests by clicking on the "debug test" text:
Debugging tests as opposed to just running them (with "run test") is useful because I can set breakpoints to observe the state of the program at arbitrary points during the test, or allow the program to continue one line at a time during a test to see what causes a panic.
The problem I encountered today is that I needed to run a test, while debugging, and I needed environment variables set for that particular test. It's more of an integration test, so it involves interacting with GCP APIs, and I needed to be able to set the GOOGLE_APPLICATION_CREDENTIALS environment variable that the test requires.
My current understanding of debugging in VS Code is that if you want to set up things like environment variables to be used by the program, you need to use a launch config. I do that by clicking on "create a launch.json file" from a Go project:
Then, I'm presented with the types of Go launch configs that VS Code can generate for me:
The problem is that none of these will work for my use case. I need to run a specific test, not run an entire Go package. I could read into how the go CLI tool works to learn for myself what I can set up, but it'd be convenient if VS Code could help me with this and keep me in the zone.
Describe the solution you'd like
I would like an easy way to generate launch configs for running particular tests in a Go project. As a bonus, it'd be nice if we could choose launch configs for all types of testing one usually does in Go (all tests, all tests in a package, all tests in a file, or just one particular test). It would be nice if I could create the launch config by clicking on some UI element near the "debug test" UI element, in which case the launch config would automatically include the right go command to run just that test.
Alternatively, if launch configs aren't the best way to solve my use case (including environment variables while running a test), something else could be implemented that would allow one to set environment variables for a test easily. Then, they could run them by clicking "debug test" or "run test" without having to set up a launch config.
Describe alternatives you've considered
Starting from the "Go: Launch Package" launch config template, consulting the go CLI tool documentation to learn how to use it to run just one test, and then adding my environment variable config to that launch config. Repeating this step for every test I need to manually debug with environment variables.