TeamCity 2018.1 Help

NUnit

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

Option

Description

NUnit runner

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

.NET Runtime

From the Platform drop-down, select the desired execution mode on a x64 machine. Supported values are: Auto (MSIL), x86 and x64. From the Version drop-down, select the desired .NET Framework version. Supported values are: v2.0, v4.0; and <auto>, available if NUnit 3.0 is selected. For NUnit 3.0, if <auto> is selected, tests will run under the framework they are compiled with.

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. In the following example, TeamCity will search for the tests assemblies in all project directories and run these tests.

**\*.dll

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. In the following example, TeamCity will omit tests specified in this directory.

**\obj\**\*.dll

Include categories

Specify NUnit categories of tests to be run. Multiple entries are comma-separated. Category expressions are supported here as well; commas, semicolons, and new-lines are treated as global or operations (prior to the expression parsing). Since NUnit 3.0 category expressions are not supported and must be set via the command line as described in the NUNit documentation.

Exclude categories

Specify NUnit categories to be excluded from the tests to be run. Multiple entries are comma-separated. Category expressions are supported here as well; commas, semicolons, and new-lines are treated as global or operations (prior to the expression parsing). Since NUnit 3.0 category expressions are not supported and must be set via the command line as described in the NUNit documentation.

Run process per assembly

Available for versions only. 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.

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.

Last modified: 20 April 2023