【发布时间】:2018-04-14 10:47:03
【问题描述】:
在 VSCode 版本 1.17.2(安装了 C# 扩展)中,我通过 dotnet new mstest 将 MSTest 项目添加到解决方案文件夹,并添加了对使用 dotnet add <project_path> 测试的程序集的引用。
鉴于下面的两个 VSCode 任务,我可以成功构建和运行测试;即一切都构建,单元测试运行并通过。
{
"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"
}
]
}
但是,我无法使用集成调试器打断点或以其他方式逐步完成单元测试。我想出的最接近的启动配置将运行测试,但调试器不会遇到断点或附加到任何东西。
{
"name": "test",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "dotnet",
"args": ["test"],
"cwd": "${workspaceRoot}/src/tests",
"stopAtEntry": true,
"console": "internalConsole"
}
我可能缺少一些基本的东西,但是如何启动或附加 vscode c# 调试器到 MSTest 单元测试?
【问题讨论】:
-
我无法让
"problemMatcher": "$msCompile"为我工作dotnet test,它对你有用吗?
标签: .net unit-testing visual-studio-code mstest