I spent long time to test my unit-test codes in VSCode. Here is the represantation steps to work the debug functionality.
create the empty folder and open it from VSCode, then move to terminal view.
enter these commands to create the projects.
> mkdir codes
> mkdir tests
> cd codes
> dotnet new console --target-framework-override net472
> cd ..\tests
> dotnet new nunit --target-framework-override net472
> dotnet add reference ..\codes\codes.csproj
> cd ..
> dotnet new sln
> dotnet sln add ..\codes\codes.csproj
> dotnet sln add ..\tests\tests.csprojsome language features in template are not allowed in .NET Framework 4.7.2. fix the codes
comment out two options::
<!-- ImplicitUsings>enable</ImplicitUsings -->
<!-- Nullable>enable</Nullable -->change codes to older style::
using System;
namespace codes {
public class Program {
public static void Main(string[] args) {
Console.WriteLine("Hello, World!");
}
}
}disable the option::
<!-- Nullable>enable</Nullable -->
discribed in C# dev kit , launch.json is needed to change.
to create the launch.json, click the link in the debug panel.
you can input with suggestion, then change coreclr to clr
here is my launch.json
{
"version": "0.2.0",
"configurations": [{
"name": ".NET Core Attach",
"type": "clr",
"request": "attach"
}]
}
after you rebuild the project or reload the window, click the debug buttons in the Test panel.



