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

x/tools/gopls: offer test function snippets as completion candidates in test files #61210

Open
findleyr opened this issue Jul 6, 2023 · 3 comments
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

findleyr commented Jul 6, 2023

Suggestion by way of @pjweinb: when typing a new function declaration in a test file (*_test.go), we could offer completion items for untested exported functions in the non-test package.

For example, if package p defines function Foo, we could offer the completion suggestion func TestFoo when typing in p_test.go.

Extra credit: populate the completion snippet with a test body that sets up a table-driven test for the function in question.

@findleyr findleyr added this to the gopls/later milestone Jul 6, 2023
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jul 6, 2023
@robbiesumner
Copy link

I think this is a great idea. 👍🏼 I could maybe work on this.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/554836 mentions this issue: gopls: offer test function completion for untested methods

@findleyr
Copy link
Contributor Author

@robbiesumner this might be tricky to implement, but you are welcome to give it a go. You'll need to walk the package scope looking at top level declarations, and pairing off exported methods with existing tests.

Let us know if you have any questions, or have anything to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants