2

I'm trying to create some tasks in Visual Studio Code to run all the tests in my go project.

I usually execute the tests on the command line using:

go test ./...

In Visual Studio Code my tasks.json looks like this:

{
    "version": "0.1.0",
    "command": "go",

    "tasks": [
        {
            "taskName": "build",
            "isBuildCommand": true
        },
        {
            "taskName": "test",
            "isTestCommand": true,
            "args": ["./..."]
        }
    ]
}

So Build works fine (CTRL + SHIFT + B)

But when I try to run the tests (CTRL + SHIFT + T) the following error occurs:

go: unknown subcommand "./..."

It seems to be omitting the "test" param, but when I comment out the args it runs go test fine.

Any ideas?

Mattl
  • 1,588
  • 3
  • 24
  • 49

1 Answers1

0

THIS MAY BE A BUG


VSCode Reverse Args and Task as of v0.8.0

This may be a bug that still persists in the newer versions. As of v0.9.1 I have not had a chance to test. Prior to 0.9.1 at least one hack worked by reversing the task and it's arg as in the following example:

{
"version": "0.1.0",
"command": "go",

"tasks": [
    {
        "taskName": "build",
        "isBuildCommand": true
    },
    {
        "taskName": "./...",
        "isTestCommand": true,
        "args": ["test"]
    }
  ]
}

It's hard to believe that this has still persisted until v0.8.0 so there may be a preferred solution that I have not discovered.

Here is a link to a prior post that deals with a similar issue:

Define multiple tasks in VSCode

Scroll down to my answer for more explanation.

Community
  • 1
  • 1
GJSmith3rd
  • 806
  • 5
  • 7