Running unit tests with Windows Terminal
We almost introduced a bug in the last section, but caught it at the last minute. We were lucky; we might not catch the next bug. Let's set up some unit tests that will run automatically and help catch future bugs.
We'll be running our unit tests in a new project. Navigate to our App
directory and create a new test project using the following command:
dotnet new xunit -o App.Tests
This will create a new project for our tests, next to our App.WebApi
project. The folder structure should now look like this:
We'll want to tell the App.Tests
project how to find our App.WebApi
project, so it can test the functionality inside. Navigate to the top-level App
folder, and run the following command:
dotnet add App.Tests reference App.WebApi
Next, in Visual Studio Code, open the App.Tests/UnitTest1.cs
file, where we'll be writing our automated...