在Visual Studio代码中调试MSTest单元测试

编程入门 行业动态 更新时间:2024-10-23 23:32:55
本文介绍了在Visual Studio代码中调试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.

推荐答案

尝试 github/Microsoft/vstest-docs/blob/master/docs/diagnose.md#debug-test-platform-components (假设您正在使用dotnet-cli工具1.0.0)

Try github/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代码中调试MSTest单元测试

本文发布于:2023-11-08 13:39:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569526.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元测试   代码   Visual   Studio   MSTest

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!