TeamCity
 
You are viewing the documentation for an earlier version of TeamCity.

NUnit

Last modified: 20 April 2023

The NUnit build runner is intended to run NUnit tests right on the TeamCity server. However, there are other ways to report NUnit tests results to TeamCity, please refer to the NUnit Support page for the details.

NUnit 3 Requirements



Installing NUnit



To use the TeamCity NUnit build runner, you need to install the NUnit NuGet package on TeamCity agents first.

To do that, use one of the following options:

  • you can add the NuGet install build step as the first step of your build configuration. For example, you can add a command line build step before the NUnit build step which will install the NUnit.Console NuGet package as follows:

    %teamcity.tool.NuGet.CommandLine.DEFAULT%\tools\nuget.exe install NUnit.Console -version 3.6.0 -o packages

    Note that %teamcity.tool.NuGet.CommandLine.DEFAULT% is a reference to NuGet installed under the TeamCity agent. You can install NuGet on agents from the Administration | Tools page, where you can also mark one of the installed NuGet versions as default. After that the %\teamcity.tool.NuGet.CommandLine.DEFAULT% parameter reference should properly resolve to the NuGet installation path on the agent. Then nunit3-console should appear under the packages directory. To run tests, in the next NUnit build step, specify the NUnit path in the NUnit settings as packages\NUnit.ConsoleRunner.3.6.0\tools\nunit3-console.exe.

  • Another approach is to install NUnit manually on all of the agents in some standard place, and configure the path to nunit-console.exe in your NUnit build step.

Installing Extensions



Starting from version 3.2.0, NUnit requires the NUnit.Extension.NUnitProjectLoaderextension to be installed on the TeamCity agent. Starting from version 3.4.1, NUnit requires the NUnit.Extension.TeamCityEventListenerextension to be installed on the TeamCity agent.

The NUnit runner checks for the extensions, and if they are not found, in versions 3.2.0 and 3.2.1 the build will fail without a warning; since version 3.4.1 a message is displayed suggesting you install them. The extensions can be installed in bulk using the NUnit Console Version 3 NuGet package or as separate packages, NUnit.Extension.TeamCityEventListener and NUnit.Extension.NUnitProjectLoader.

NUnit Test Settings



Code Coverage



To learn about configuring code coverage options, please refer to the Configuring .NET Code Coverage page.

For NUnit 3.x, only JetBrains dotCover is supported as a coverage tool.