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

Is there an easy way to make this work with VSCode #120

Open
acgreek opened this issue Jan 27, 2020 · 3 comments
Open

Is there an easy way to make this work with VSCode #120

acgreek opened this issue Jan 27, 2020 · 3 comments

Comments

@acgreek
Copy link

acgreek commented Jan 27, 2020

Using vanilla gotest testing, vscode is able to identify that a function is a test and provide link above the test function to run the test. By default, it does not do this for check.v1 test methods. Is there a way to make it work? If so, documentation would be nice

@acgreek
Copy link
Author

acgreek commented Jan 31, 2020

looked into this a little bit more and noticed there is still a test function up at the top that works with VScodes I can use to run all the tests in the suite. It would be nice to have a way to run the individual tests in the suite using that some ctrl-p action. Maybe, I will write an extension for this

@bk800
Copy link

bk800 commented May 5, 2022

We are using this, and one of my colleagues figured it out. Here is an example:

  1. Build a test file with "go test -c". Lets say its in the location $GOPATH/src/examples/example.test

  2. In vscode, go to "Run"->"Open Configurations" (or "Add Configuration")

Add something like this:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Example Suite",
            "type": "go",
            "request": "launch",
            "mode": "exec",
            "program": "${workspaceFolder}/src/examples/example.test",
            "args": [
                "--check.f=TestExample_001",
            ],
        },
    ]
}
  1. Install dlv if needed
    go get -u github.com/go-delve/delve/cmd/dlv

  2. Start Debugging (F5)

More Info:
https://code.visualstudio.com/docs/languages/go#_debugging

@SimonRichardson
Copy link

This vscode plugin[1] does what you want. It uses a regexp to lookup test locations and allows you to run a test from inside the editor.

  1. https://github.com/babakks/vscode-go-test-suite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants