Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Unit test generation should consider the receiver type #2282

@Guitarbum722

Description

@Guitarbum722

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

  1. right click a method name
  2. select "Generate Unit Tests for Function
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions