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

Generate unit test for functions with variable semantics #1927

Closed
nathan-boulestin opened this issue Dec 3, 2021 · 1 comment
Closed

Generate unit test for functions with variable semantics #1927

nathan-boulestin opened this issue Dec 3, 2021 · 1 comment

Comments

@nathan-boulestin
Copy link

Is your feature request related to a problem? Please describe.
We declare functions with the variable semantics to make mocking a lot easier.
For example we will declare var MyFunc= func() instead of func MyFunc()
The commands for generating unit tests does not recognize this semantic as functions and does no generate any unit test template.

Describe the solution you'd like
I would like the commands for generating units tests to also work for the variable semantic.
So a function declared var MyFunc= func() would produce the same unit test as func MyFunc().

Describe alternatives you've considered
As an alternative I made a regex to convert functions to each declaration semantic using text replace:
var MyFunc= func() -> func MyFunc():
match: var ([a-zA-Z]*) = func(\([a-zA-Z\s\.\*]*\))
replace: func $1$2

func MyFunc() -> var MyFunc= func():
match: func ([a-zA-Z]*)(\([a-zA-Z\s\.\*]*\))
replace: var $1 = func$2

I have to convert the functions, use the generate unit tests command, and then convert back the functions semantic.

@gopherbot gopherbot added this to the Untriaged milestone Dec 3, 2021
@suzmue suzmue modified the milestones: Untriaged, Unplanned Dec 3, 2021
@suzmue
Copy link
Contributor

suzmue commented Dec 3, 2021

We are planning to move the test generation feature into gopls (#1594).

The issue tracking the migration of tools is available in #1652.

@golang golang locked and limited conversation to collaborators Jul 11, 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