如何使用 .Net Core 和 VSCode 在调试模式下执行测试? [英] How do I do I execute tests in Debug mode using .Net Core and VSCode?
本文介绍了如何使用 .Net Core 和 VSCode 在调试模式下执行测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用 .Net Core 和 VSCode 在调试模式下执行测试?
我目前正在命令行上运行以下命令:
dotnet 测试
然而,这不是在调试模式下执行测试.
我是否附加调试器?
如果是...怎么办?
解决方案
- 如有必要,将测试项目转换为控制台应用程序,而不是库.例如,使用
- 添加一个主要的方法或函数.
<前>//F#模块程序 =[<入口点>]让 main(args: string[]) = 0
在 main 中,调用您要调试的测试.
在调试器中运行控制台应用程序(通常按 F5).
这应该不会影响运行 dotnet test
.
How do I execute tests in Debug mode using .Net Core and VSCode?
I am currently running the following on the command line:
dotnet Test
However, this is not executing the tests in debug mode.
Do I attach a debugger?
If so... How?
解决方案
- If necessary, convert the test project to be a console app, instead of a library. For example, use
<TargetFramework>netcoreapp2.0</TargetFramework>
- Add a main method or function.
// C# class Program { static void Main(string[] args) { } }
// F# module Program = [<EntryPoint>] let main(args: string[]) = 0
In the main, call the test that you want to debug.
Run the console application in the debugger (usually pressing F5).
This should have no effect on running dotnet test
.
这篇关于如何使用 .Net Core 和 VSCode 在调试模式下执行测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文