相关疑难解决方法(0)

如何在 VSCode 中调试 MSTest?

在 VSCode 的 1.17.2 版(安装了 C# 扩展)中,我通过将一个 MSTest 项目添加到解决方案文件夹中,dotnet new 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"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

但是,我无法使用集成调试器点击断点或以其他方式单步执行单元测试。我提出的最接近的启动配置将运行测试,但调试器不会命中断点或附加到任何内容。

    {
        "name": "test",
        "type": …
Run Code Online (Sandbox Code Playgroud)

.net unit-testing mstest visual-studio-code

7
推荐指数
1
解决办法
3979
查看次数

标签 统计

.net ×1

mstest ×1

unit-testing ×1

visual-studio-code ×1