How do I do I execute tests in Debug mode using .Net Core and VSCode?

喜夏-厌秋 提交于 2019-12-10 01:39:59

问题


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?


回答1:


  1. If necessary, convert the test project to be a console app, instead of a library. For example, use

<TargetFramework>netcoreapp2.0</TargetFramework>

  1. Add a main method or function.

    // C#
    class Program
    {
        static void Main(string[] args)
        {
        }
    }
    // F#
    module Program =
        [&ltEntryPoint&gt]
        let main(args: string[]) = 0
  1. In the main, call the test that you want to debug.

  2. Run the console application in the debugger (usually pressing F5).

This should have no effect on running dotnet test.



来源:https://stackoverflow.com/questions/45526413/how-do-i-do-i-execute-tests-in-debug-mode-using-net-core-and-vscode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!