Adding a Test Task to the VS Code Command Palette

I like building my projects using the using tasks from VS Code Command Palette, I do it without even thinking.

But running tests is not the same. When I try to run a test task, I first open the palette, try to run the test.

But since I don’t have any configured, I am offered the option to configure one.

But the configure option does nothing for me, it reopens my tasks.json and makes no changes to the file.

Adding the test task by hand

Open the .vscode/tasks.json file. Add the below to the tasks array.

1
2
3
4
5
6
7
8
9
{
    "label": "test",
    "command": "dotnet",
    "type": "process",
    "args": [
        "test"
    ],
    "isTestCommand": true
}
 

Now, when I go to the command palette, I have a new test task.

Select that and my tests run.

comments powered by Disqus

Related