1

I usually run go test ./... to run all tests in my project.

How can I set up launch.json to debug every tests that normally go test ./... runs?

1
  • What do you mean by "debug every test"? Do you simply want to run every test? Or do you mean something else? Commented Jun 1, 2020 at 13:07

2 Answers 2

1

Assuming you're using the Go extension for VSCode:

As the vscode-go's documentation says, you could use the following:

{
    "name": "Launch test package",
    "type": "go",
    "request": "launch",
    "mode": "test",
    "program": "${workspaceFolder}"
}

Note that you're specifying a new mode called "test".

You have to install delve in order to debug code using VSCode. You can install it by yourself or use the Go: Install/Update Tools command from VSCode. Read the documentation I mention first for more information.

Sign up to request clarification or add additional context in comments.

2 Comments

This only tests inside workspaceFolder but not tests in the folders under it!
{ "name": "Launch test package", "type": "go", "request": "launch", "mode": "test", "program": "${workspaceFolder}" }
0

This one should work

{
   "name": "Launch test package",
   "type": "go",
   "request": "launch",
    "mode": "test",
    "program": "${workspaceFolder}/controllers" 
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.