-
$ dotnet new console -n Leetcode
It will create a folderLeetcode/
and keep everything in it. -
$ dotnet new xunit -o Leetcode.Test
It will create another folderLeetcode.Test
and keep everything in it. So, far these 2 projects are independent, and no connection to each other. -
$ dotnet add Leetcode.Test/Leetcode.Test.csproj reference Leetcode/Leetcode.csproj
It will add the Leetcode entry into Leetcode.Test -
Make your changes
-
$ dotnet build
OR$ dotnet test
OR$ dotnet run
- Other options:
$ dotnet test --filter FullyQualifiedName~L0140
# to run tests only for a certain namespace
- Other options:
In this way you can control the project via terminal. However, you cannot run a debug.
- install C# Dev Kit and formulahendry.dotnet-test-explorer extension.
- Open vscode into new folder
- Command Pallette >
.NET new project
>Console App
> Folder name =Leetcode
It will create a new folderLeetcode\
, along with other settings as well. - Command Pallette >
.NET new project
>xUnity New Project
> Folder name =Leetcode.Test
- By now, you should be able to test via
Test Explorer
OR$ dotnet test
$ dotnet add Leetcode.Test/Leetcode.Test.csproj reference Leetcode/Leetcode.csproj
It will add the Leetcode entry into Leetcode.Test- To debug
- Add breakpoints.
- use Command Pallette >
Test: Debug All test
ORTest: Debug Tests in Current File
- Other options:
Test: Debug Last Run
ORTest: Debug Failed Tests
- Other options: