在 Visual Studio Code 中调试 MSTest 单元测试

标签 debugging .net-core visual-studio-code mstest

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

这是我的 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 也存在同样的问题。

最佳答案

如果您使用的是最新版本的 VS Code(我使用的是 v1.29.0),调试单元测试是内置功能。<​​/p>

enter image description here

您需要首先构建解决方案dotnet build才能显示测试运行和调试选项。

关于在 Visual Studio Code 中调试 MSTest 单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43210794/

相关文章:

eclipse - Node.js Express 应用程序无法在 Eclipse (Nodeclipse) 中启动(或调试)

visual-studio-code - 如何在 vscode 中设置片段的光标选择?

Kubernetes集群中的Nginx微服务网关配置

c# - 如何跟踪 Entity Framework Core 事件以进行集成测试?

c# - NET核心后台服务: "A task was canceled." Error

c++ - 在 Visual Studio Code 中为 C++ 创建一个新类?

angular - typescript 中的函数定义错误

php - 是否可以将调试器附加到正在运行的 PHP 进程?

javascript - 在页面最初加载时执行淡入?

Java 访问局部变量名