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    "label": "test",
3    "command": "dotnet",
4    "type": "process",
5    "args": [
6        "test"
7    ],
8    "isTestCommand": true
9}
 

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