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

Support to run single test case in table driven unit test #3091

Closed
mingqishao opened this issue Dec 13, 2023 · 2 comments
Closed

Support to run single test case in table driven unit test #3091

mingqishao opened this issue Dec 13, 2023 · 2 comments

Comments

@mingqishao
Copy link

mingqishao commented Dec 13, 2023

Is your feature request related to a problem? Please describe.
We usually use table driven in unit test. Here is a simple example. Our problem is I can't run single test case. If one test failed and I want to run it again. I have to comment out all other test case, then run the whole xxx_Test() function.

Describe the solution you'd like
Support run the single test case in table driven unit test like subtest today.

@gopherbot gopherbot added this to the Untriaged milestone Dec 13, 2023
@jim-minter
Copy link

Adding more detail. The screenshot below shows a "traditional" test approach using t.Run() for sub-tests, and an equivalent table-driven approach. In the traditional approach, individual sub-tests can be executed directly from vscode by clicking the "run test" label that appears. It would be amazing if the same thing were possible in the table driven approach, i.e. if vscode could recognise that each entry in the slice being ranged represents a sub-test, and provided a separate "run test" label for it by the struct definition.

Clearly it wouldn't be possible to support arbitrarily complex non-constant arguments for t.Run, or arbitrarily complex table-driven test implementations, but I'd have thought that it should be possible to support tests with a single t.Run call, where the name references a struct field in a slice which is being ranged? Being able to do this would be incredibly useful!

Screenshot_2023-12-13_11-22-31

@jim-minter
Copy link

I think this is a duplicate of #2445.

@golang golang locked and limited conversation to collaborators Dec 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants