本文介绍如何设置 VS Code 设置以将调试目标指向单元测试项目的构建输出。因此,我将我的设置如下:
{
"explorer.confirmDragAndDrop": false,
"git.allowForcePush": true,
"git.autofetch": true,
"window.zoomLevel": 0,
"csharp.unitTestDebuggingOptions": {
"sourceFileMap": {
"C:\\git\\MsTester\\bin\\Debug\\netcoreapp2.1": "C:\\git\\MsTester\\bin\\Debug\\netcoreapp2.1"
}
},
"files.autoSave": "afterDelay",
"files.exclude": {
"**/bin": true,
"**/node_modules": true,
"**/obj": true
},
"csharpfixformat.style.spaces.insideEmptyBraces": false,
"csharpfixformat.style.braces.allowInlines": false,
"csharpfixformat.style.spaces.beforeParenthesis": false,
"csharpfixformat.style.spaces.afterParenthesis": false,
"csharp.format.enable": false,
"extensions.ignoreRecommendations": true
}
但是,我不确定如何设置launch.json
启动dotnet test
它以便它可以附加调试器。
这是我目前所拥有的:
{
"version": "0.2.0",
"configurations": [
{
"name": "MsTester",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/MsTester/bin/Debug/netcoreapp2.1/MsTester.dll",
"windows": {
"args": [
"--filter",
"TestCategory=lbshell",
"--logger",
"trx",
"--results-directory",
".\\TestResults",
"--settings",
".\\Features\\runsettings.xml"
],
},
"cwd": "${workspaceFolder}/MsTester",
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
]
}
是否有一个选项告诉 VS Code 它需要执行dotnet test
而不是dotnet run
?
我希望这个页面能说明如何做到这一点,但事实并非如此。