在 Visual Studio Code 中调试 MSTest 单元测试 [英] Debugging MSTest Unittests in Visual Studio Code

查看:33
本文介绍了在 Visual Studio Code 中调试 MSTest 单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Visual Studio Code 调试 MSTest 单元测试项目.但测试只是运行,断点从未到达.

I am trying to use Visual Studio Code to Debug a MSTest unit test project. But the tests just run and the breakpoint is never reached.

这是我的launch.json:

Here is my launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Test (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "C:\Program Files\dotnet\dotnet.exe",
            "args": ["test"],
            "cwd": "${workspaceRoot}",
            "console": "internalConsole",
            "stopAtEntry": false,
            "internalConsoleOptions": "openOnSessionStart"
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickProcess}"
        }
    ]
}

如何调试单元测试 (MSTest)?XUnit 也存在同样的问题.

How can I debug a unit test (MSTest)? This same problem exists for XUnit.

推荐答案

尝试 https://github.com/Microsoft/vstest-docs/blob/master/docs/diagnose.md#debug-test-platform-components(假设你重新使用 dotnet-cli 工具 1.0.0)

Try https://github.com/Microsoft/vstest-docs/blob/master/docs/diagnose.md#debug-test-platform-components (assumes you're using dotnet-cli tools 1.0.0)

> set VSTEST_HOST_DEBUG=1
> dotnet test
# Process will wait for attach
# Set breakpoint in vscode
# Use the NETCore attach config from vscode and pick the dotnet process

这篇关于在 Visual Studio Code 中调试 MSTest 单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆