In version 1.17.2 of VSCode (with the C# extenion installed) I have added an MSTest project to a solution folder via dotnet new mstest
and added a reference to the the assembly being tested with dotnet add <project_path>
.
Given the two VSCode tasks below I can build and run the tests successfully; i.e. everything builds, the unit tests run and pass.
{
"version": "2.0.0",
"tasks": [
{
"taskName": "build",
"command": "dotnet build src/tests/tests.csproj",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
},
{
"taskName": "test",
"command": "dotnet test src/tests/tests.csproj",
"type": "shell",
"group": {
"kind": "test",
"isDefault": true
},
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
}
I cannot however hit breakpoints or otherwise step through the unit test with the integrated debugger. The closest launch configuration I've come up with will run the tests but the debugger doesn't hit breakpoints or attach to anything.
{
"name": "test",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "dotnet",
"args": ["test"],
"cwd": "${workspaceRoot}/src/tests",
"stopAtEntry": true,
"console": "internalConsole"
}
I may be missing something fundamental but how does one launch or attach the vscode c# debugger to an MSTest unit test?