-
Notifications
You must be signed in to change notification settings - Fork 798
extension: Test Suite Fails to Parse Subtests Correctly #3725
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
Comments
Hi @caioreix I can confirm the sub test "Success" can not be correctly triggered using the code lenses provided. It end up using
I was able to use the code lenses to trigger test for
But I can not run test using the command you provided (it passes but it actually does not run any test)
Am I constructing the command wrong? In addition, |
hello @h9jiang!
No, the command itself is correct, but it still doesn’t work because |
@caioreix Are you using an older version of testify? Newer versions do use subtests and don't require the That being said, I'm not sure that the legacy test support or either explorer implementation builds the flag correctly. Go Companion may because that was written after CL 343883. |
Thank you so much for your input here. I'm not familiar with testify framework but I'm glad to see that testify no longer require If this works, I don't think we really need to introduce
Current test support build testify test correctly but does not build testify subtest correctly. The testify test is build using the special handling We can make some changes in current vscode-go's test to cleanup those testify related special handling and make this testify subtest work but I wonder if this is something worth doing. Consider the Go Companion is under-development and it works for testify subtest, it might not worth changing the existing vscode-go since it's going to be replaced by Go Companion. Temporarily move it from v0.48.0 milestone to backlog. |
Since the testing part will be replaced by Go Companion, I don't see a problem leaving this implementation for when the migration happens. However, while testing with Go Companion, I noticed that tests written with testify are not recognized by the Test Explorer at the moment. Only functions in the format |
Correct; Go Companion eliminates JavaScript based test discovery in favor of using gopls, and that's a new feature (for gopls) which doesn't have support for frameworks like testify. That is something I'd like to add but my main focus for now is supporting table-driven tests. That being said, they should appear once you execute the test. Granted, those test items are "dynamic" subtests and thus don't have a location (because |
Describe the bug
When the code len of a subtest suite is called, it ends up causing an incorrect parse of the function, thus not properly generating the test command. It results in something like:
go test -timeout 30s -coverprofile=/tmp/vscode-xxx/go-code-cover -run ^\(\*testSuite\)\.TestSuite_Example$/^Success$ test
The expected output would be something like:
go test -timeout 30s -coverprofile=/tmp/vscode-xxx/go-code-cover -run ^TestSuite$ -m ^(TestSuite_Example$/^Success)$ test
This is happening due to escaping both the function name and the subtest name in this line:
vscode-go/extension/src/subTestUtils.ts
Lines 17 to 23 in 77a4fdb
Escaping only the second part would already solve the problem:
https://github.com/caioreix/vscode-go/blob/6061299ff2b1526292a9e1aeff77bf77b3f88f67/extension/src/subTestUtils.ts#L17-L25
Steps to reproduce the behavior:
To reproduce it, you can use the snippet below and click on the codelens 'run test' corresponding to the Success or Fail subtest (I used testify to make visualization easier, but the behavior is the same for any test suite):
The text was updated successfully, but these errors were encountered: