Skip to content

Instantly share code, notes, and snippets.

@ByteDev
Last active May 20, 2021 03:33
Show Gist options
  • Save ByteDev/19bd9bfcb6bf55ed5c72475d71a04e60 to your computer and use it in GitHub Desktop.
Save ByteDev/19bd9bfcb6bf55ed5c72475d71a04e60 to your computer and use it in GitHub Desktop.
How to quicky create a new .NET Core NUnit test project.

Creating a NUnit test project

1. Create new .NET Core project

Delete any Program.cs file that might have been automatically added to the project.

2. Edit the .csproj file

Remove:

    <OutputType>Exe</OutputType>

Add:

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
    <PackageReference Include="NUnit" Version="3.13.1" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
  </ItemGroup>

Your final .csproj file should look something like:

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

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
    <PackageReference Include="NUnit" Version="3.13.1" />
    <PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
  </ItemGroup>

</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment