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
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:
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
- 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.
Starting from version 3.2.0, NUnit requires the
NUnit.Extension.NUnitProjectLoader extension to be installed on the TeamCity agent.
Starting from version 3.4.1, NUnit requires the
NUnit.Extension.TeamCityEventListener extension 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 Test Settings
Select the NUnit version to be used to run the tests. The number of settings available will vary depending on the selected version.
Path to NUnit console tool:
Available if NUnit 3.0 is selected. Specify the path to nunit3-console.exe:prior to TeamCity 9.1.4 specify the directory containing the console executable file,
since 9.1.4 specify the path to the console executable file including the file name.
|Working directory||Available if NUnit 3.0 is selected. Optional. Specify the path to the build working directory if it differs from the directory of the testing assembly.|
Path to application configuration file
|Available if NUnit 3.0 is selected. Specifу the path to the application configuration file to be used when running tests. The path is absolute or relative to the checkout directory.|
Additional command line parameters
Available if NUnit 3.0 is selected. Enter additional command line parameters to pass to nunit-console.exe
From the Platform drop-down, select the desired execution mode on a x64 machine. Supported values are:
Run tests from
Specify the .NET assemblies where the NUnit tests to be run are stored. Multiple entries are comma-separated; usage of MSBuild wildcards is enabled. The paths to assembly files are absolute or relative to the checkout directory.
Do not run tests from
Specify .NET assemblies that should be excluded from the list of assemblies to test. Multiple entries are comma-separated; usage of MSBuild wildcards is enabled. The paths to assembly files are absolute or relative to the checkout directory.
Specify NUnit categories of tests to be run. Multiple entries are comma-separated.
Specify NUnit categories to be excluded from the tests to be run. Multiple entries are comma-separated.
Run process per assembly
Available for versions prior to NUnit 3.0 only (since TeamCity 9.1.6). Select this option if you want to run each assembly in a new process.
Reduce test failure feedback time
Use this option to instruct TeamCity to run some tests before others.
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.