Scott Nimrod
Scott Nimrod

Reputation: 11595

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

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?

Upvotes: 12

Views: 2366

Answers (1)

Wallace
Wallace

Reputation: 17369

  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 =
        [<EntryPoint>]
        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.

Upvotes: 6

Related Questions