-
Notifications
You must be signed in to change notification settings - Fork 758
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
Allow "subtest at cursor" to work with table-driven test setup #1602
Comments
Hi, this feature is available: Does that meet your needs? |
Unfortunately, "Go: subtest at cursor" is pretty limited at the moment and does not work with table driven tests. Where would you expect the code lens to appear? In the definition of tests? On t.Run (with some way to specify which subtest)? It would be reasonable for Issue #1579 is tracking updates to testing support for this extension, which may add some support for easier subtest running. |
Yes, it will be helping us a lot. |
Glad to see some Ideas around this, My opinion is to have code lens appear at definition of the test |
We couldn't do this in generality (for example if the test cases were outside the function scope), but it wouldn't be hard for gopls to provide code lenses for the common patterns of a slice of test cases in the function scope, or ranging over a literal. We could add this feature as part of our migration to use gopls for generating test code lens. |
okay |
I guess users will still want to enter or select the subtest name after clicking a codelens. Currently, I don't think LSP's codelens+command allows that level of UX control yet. So the extension will need a middleware hack or the actual codelens implementation (based on info from gopls) if we want to implement it soon. |
Change https://golang.org/cl/333309 mentions this issue: |
@schandra157 Once VSCode's testing API is finalized and #1579 is merged, you will be able to see specific subtests, though there are some limitations. Discovering subtests statically is problematic, so at the moment, I add subtests while running a test, any time I see a So the test explorer will list subtests. But every feasible method I can think of for discovering where a subtest was defined has edge cases that wouldn't work. And the only method I can think of that would always work would involve executing the code, which is not really something we can feasibly do at the moment. What we can recognize (probably)
What won't work
|
Updates #1602 Change-Id: Ibcea9c5980c6c08257f0c6925502eb0b9fd00cdb Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/333309 Trust: Suzy Mueller <[email protected]> Trust: Hyang-Ah Hana Kim <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
How about a simpler solution such as adding command |
@pckhoi It's not clear to me that such a command would provide value. The user can already run |
Except I never run tests on the command line anymore but mostly rely on "Go: Test Package" command. Sure I could run things on the command line but I also lose any integration with vscode, including custom settings I have defined in |
@pckhoi I suggest you open a separate feature request, including your explanation here. "Add a command that allows me to specify a custom value for the The can both be used for similar purposes, but they take a fundamentally different approach, and must be implemented differently. Plus, if I can find a way to detect table-driven tests, this issue will likely be closed as resolved. |
I'm coming from Goland(JetBrains). Digging a bit, I realized that we can run a specific test case into a table-driven. This seems to be related to the topic:
Ref: https://github.com/golang/vscode-go/blob/master/docs/commands.md#go-subtest-at-cursor I hope it helps to someone. |
any updates? |
Change https://go.dev/cl/601015 mentions this issue: |
Change https://go.dev/cl/548675 mentions this issue: |
Implements test discovery. Tests are discovered as part of the type checking process, at the same time as method sets and xrefs, and cached. Does not implement the Modules command. Adds static detection of simple subtests. This provides a framework for static analysis of subtests but intentionally does not support more than the most trivial case in order to minimize the complexity of this CL. Fixes golang/go#59445. Updates golang/go#59445, golang/vscode-go#1602, golang/vscode-go#2445. Change-Id: Ief497977da09a1e07831e6c5f3b7d28d6874fd9f Reviewed-on: https://go-review.googlesource.com/c/tools/+/548675 Reviewed-by: Alan Donovan <[email protected]> Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
It is feasible for gopls to add static detection of simple table-driven subtests. However since #2445 already exists, I think it is better for this issue to be more specifically about: "As a user, when I have selected a table entry of a table driven test, I want |
Small note regarding the test entry location: I use |
Related issues
Is your feature request related to a problem? Please describe.
In the case of Table driven Test model in GO programming, Currently, it's possible to run/debug test at the Function level. It would be great if its possible to be executed at the individual test level
Describe the solution you'd like
Have an option to Run and Debug at each individual Test level, which would be great to debug the individual test in case of issue and would be very handy feature
Additional context
The below Screen shot describes the problem
The text was updated successfully, but these errors were encountered: