Here are some guides to setup a Shouldly project.
In this guide, we will set up a project with Shouldly unit tests.
We won't use Visual Studio, we will build our project bare bones with Dotnet CLI and a text editor.
The project structure will be as follows:
- 1.Create your root directory, name it your project name.
- 2.Open a terminal in your root directory.
dotnet new sln.
- 4.Go into program folder and run
dotnet new classlib.
- 5.Rename Class1.cs to Program.cs.
- 6.Add the following code to Program.cs:
public static class Program
public static string TestWorks()
Go to the root folder and run
dotnet sln add program/program.csproj, in order to add program to your solution.
In this part we will create the unit tests for the main program.
- 1.Move to test folder and run
dotnet new nunit(you can use others unit tests frameworks but in this guide we will stick to nunit).
- 2.Add a reference to the main program by running
dotnet add reference ../program/program.csproj
- 3.In the root folder add the tests to the solution by running
dotnet sln add test/test.csproj.
Now comes the important part, when we actually add Shouldly.
- 1.Go to the test folder and run
dotnet add package Shouldly, to add Shouldly as a NuGet Package.
- 2.Add the following code to UnitTest1.cs:
public class Tests
public void Test1()
To test your project, in your root folder run
And there you go, you have a basic project with unit tests using Shouldly.
We created a classlib project using Dotnet CLI Tools, then added unit tests and added Shouldly as a NuGet package to be able to use Shouldly in our tests.