The latest version of VS Code already provides an easy way of running a single test as pointed on Tyler Long\'s answer to the question Debugging xunit tests in .NET Core and
To run tests in Visual Studio (VS) Code, you need to add a tasks.json file to the .vscode directory (if you don't already have it). Then configure your test task as follows:
{
"version": "2.0.0",
"tasks": [
{
... // Other tasks
},
{
"label": "test",
"command": "dotnet",
"type": "shell",
"args": [
"test",
"${workspaceFolder}/TestProjectName/TestProjectName.csproj"
],
"group": "test",
"problemMatcher": "$msCompile",
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
]
}
When you have that saved, run the following command Cmd-Shift-P on Mac or Ctrl-Shift-P on Linux and Windows within the VS Code interface then type Run Test Task, press Enter and select test.
The above configuration should work for the latest Insider and Stable releases of VS Code as at April 2020 (version 1.41).