Implementing .NET Tests with xUnit

Learn to implement .NET tests in xUnit.

We are going to implement some backend unit tests on our question controller using a library called xUnit. Before we do this, we are going to become familiar with xUnit by implementing some unit tests on a class with no dependencies.

Getting started with xUnit

We are going to create a new project in our backend Visual Studio solution and start to implement simple unit tests to get comfortable with xUnit, which is the tool we are going to use to run our backend tests.

Steps to implement simple unit tests

So, let's open our backend project and carry out the following steps:

  1. Open up the “Solution Explorer” window, right-click “Solution”, choose “Add”, and then choose “New Project...”.

  2. Select “xUnit Test Project” from the dialog box that opens and click the “Next” button:

Get hands-on with 1400+ tech skills courses.