12

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?

Scott Nimrod
  • 11,206
  • 11
  • 54
  • 118

1 Answers1

6
  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.

Wallace Kelly
  • 15,565
  • 8
  • 50
  • 71