Description:
The Go Plugin doesn't seem to consider the receiver type for a method. So, if there are >= 1 method names in the same file, then clicking "generate unit tests for function" creates test functions for all of them.
This references an issue with gotests. However, that same gotests issue explains that the receiver type is in fact supported.
I tried this by running the following (as an example) in the command line using gotests directly.
$ gotests -w -only ^PersonValidate$ .
This works as expected, and there is only a test function generated for the Person type.
Version of VS Code, the Go plugin and Go:
VSCode: 1.30.2 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8 x64
Go Plugin: 0.8.0
Go: 1.11.2 darwin/amd64
OS/Platform you are working on
MacOS / AMD64
Reproducible steps (1... 2... 3...) that cause the issue
- right click a method name
- select "Generate Unit Tests for Function
- all methods that share the same name but are on different types have a test function generated
What you expected to see, versus what you actually saw
I would expect that the Go extension uses gotests with the -only flag and prepends the type name with the regexp. Therefore, one single test function is generated for the respective method that was selected.
Instead, any methods that have the same name in the file have a test function generated.
Great extension though! 👍 Hopefully this is enough info.
Description:
The Go Plugin doesn't seem to consider the receiver type for a method. So, if there are
>=1 method names in the same file, then clicking "generate unit tests for function" creates test functions for all of them.This references an issue with
gotests. However, that same gotests issue explains that the receiver type is in fact supported.I tried this by running the following (as an example) in the command line using
gotestsdirectly.$ gotests -w -only ^PersonValidate$ .This works as expected, and there is only a test function generated for the
Persontype.Version of VS Code, the Go plugin and Go:
VSCode:
1.30.2 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8 x64Go Plugin:
0.8.0Go: 1.11.2 darwin/amd64
OS/Platform you are working on
MacOS / AMD64
Reproducible steps (1... 2... 3...) that cause the issue
What you expected to see, versus what you actually saw
I would expect that the Go extension uses
gotestswith the-onlyflag and prepends the type name with the regexp. Therefore, one single test function is generated for the respective method that was selected.Instead, any methods that have the same name in the file have a test function generated.
Great extension though! 👍 Hopefully this is enough info.