NUnit testing using the new project format

This is a short recipe for how to set up your project for NUnit testing usign the new project format

Microsoft Visual Studio supports two project formats. The new format uses package references and are much simpler than the old one. It will also pick up any C# file in your folder, so you don’t need to add them explicitly.

All you need to do to use NUnit with the new format is as shown in the example csproj below. The target framework can be any of the .net framework ones. For information on using .net core, see a short recipe for that

<Project Sdk="Microsoft.NET.Sdk">


 <PackageReference Include="NUnit" Version="3.10.1" />
 <PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />


That’s all!

1. You don’t really need the LangVersion, but this is the way to ensure you have the latest minor version of C# enabled.
2. It can be wise to add the following two attributes to the first propertygroup, to set the assembly and namespace to something specific, and not rely on the default mapping:

  1. For more details on .net framework versions, see this and this