Debugging MSTest Unittests in VisualStudio Code

这一生的挚爱 提交于 2019-12-01 20:20:30

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

If you are using the latest version of VS Code (I'm using v1.29.0), debugging unit test is in-built feature.

You need to first build the solution dotnet build for the test run & debug options to appear.

Try and reload VS Code, worked for me. Press Ctrl+Shift+P which opens the command palette and then :

Reload Window

Before building, remember to include in your .csproj file

<GenerateProgramFile>false</GenerateProgramFile>

or else it will not know what to run...

Program.cs(160,21): error CS0017: Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point. [/Users/.../Fraction.csproj]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!