Skip to content

kperath/go-subtest

Repository files navigation

go-subtest

Quickly generate json required in your launch.json for your Go subtests.

gopher

Logic on adding a subtest

  1. Check if current file is a Go file
  2. Check if function is a Go test function (starts with 'Test')
  3. Checks if cursor is on a string and assumes this is the title of the subtest (this is the user's responsibility)
  4. Generates launch test configuration with the name function test name + sub test name
  5. Adds it to the launch.json file in the workspace (or if useClipboard is enabled, the JSON is copied to the clipboard instead)

Demo

demo (gif)

Requirements

Requires the Go VSCode extension in order to parse symbols and determine you are in a test function.

Limitations

This extension does not support multi-root workspaces and will just use the one it retrieves first from the API to determine the launch.json file it needs to inject to.

Extension Settings

This extension contributes the following settings:

  • "go-subtest.useClipboard": false When enabled, pastes the generated json for the subtest into your clipboard instead of adding it directly to your launch.json (for those that want to self manged)

Known Issues

Debug logs show an error: Failed to list imports: {err} but this doesn't seem to impact the extension.

Release Notes

Users appreciate release notes as you update your extension.

0.1.0

Initial release of go-subtest

  • add your subtest to launch.json or copy to your clipboard with the setting "go-subtest.useClipboard": true
  • go to your subtest config in launch.json

Following extension guidelines

Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension.

Enjoy!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published