TeamCity Cloud 2024.07 Help

NUnit

The NUnit build runner is designed to run NUnit tests on the TeamCity server. However, you can also use the .NET runner to launch NUnit tests and view test reports in TeamCity. Refer to the NUnit Support in TeamCity article for more information.

Legacy and Updated NUnit Runners

Version 2024.07 introduces an updated NUnit runner that, compared to the legacy runner, does not allow you to select a .NET Runtime or .NET Framework version. If needed, use the Additional command line parameters field to specify these settings. In addition, the updated runner no longer supports outdated NUnit 2.x.x versions.

In version 2024.07, both updated and legacy runners are fully functional and available from the Build Steps page. In the following release cycles we expect to unbundle the legacy runner and move it to a separate plugin. When it is done, you will need to manually install this plugin from JetBrains Marketplace to continue using the legacy runner. As such, we recommend migrating your projects to either updated NUnit or regular .NET runners.

Installing NUnit

To use the NUnit build runner, you need to install the NUnit NuGet package on TeamCity agents via one of the following options:

  • Instruct the first build step to install NUnit from a NuGet package.

    For example, you can add a Command Line 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

    The %teamcity.tool.NuGet.CommandLine.DEFAULT% string is a reference to the NuGet installed under the TeamCity agent.

    You can install NuGet on agents on the Administration | Tools page, where you can also mark any 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 package directory.

  • Install NUnit manually to a standard location on all the build agents 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.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.
If the extensions 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 will be displayed suggesting you install them.

The extensions can be installed as separate packages or in bulk using the NUnit Console Version 3 NuGet package.

NUnit Test Settings

Legacy and updated NUnit runners exhibit a few differences.

Updated Runner Settings

Setting

Description

NUnit Console

Select a preinstalled console tool or specify a custom path to the nunit3-console.exe console executable, including the filename.

Working directory

Specify the path to the build working directory if it differs from the directory of the testing assembly.

Path to application configuration file

Specifу the path to the application configuration file to be used when running tests. The path should be either absolute or relative to the checkout directory.

Additional command line parameters

Enter additional command line parameters to pass to nunit-console.exe.

Run tests from

Specify the .NET assemblies where the NUnit tests stored. Multiple entries should be comma-separated. The MSBuild wildcards are supported. The paths to assembly files should be absolute or relative to the checkout directory.

In the example, TeamCity will search for the tests assemblies in all the project directories and run these tests:

**\*.dll

Wildcards are specified relatively 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 should be comma-separated. The MSBuild wildcards are supported. The paths to assembly files should be absolute or relative to the checkout directory.

In the example, TeamCity will omit tests specified in this directory:

**\obj\**\*.dll

Wildcards are specified relatively to the checkout directory.

Include categories

Specify NUnit categories of tests to be run. Multiple entries should be comma-separated.
Category expressions are supported 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 should be 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.

Reduce test failure feedback time

Use this option to instruct TeamCity to run some tests before others.

Legacy Runner Settings

Setting

Description

NUnit runner

Select the NUnit version to be used to run the tests. The set of available settings varies depending on the selected version.

NUnit Console

Select a preinstalled console tool or specify a custom path to the nunit3-console.exe console executable, including the filename.

This option is available only if NUnit 3.0 is selected.

Working directory

Specify the path to the build working directory if it differs from the directory of the testing assembly.

This option is available only if NUnit 3.0 is selected.

Path to application configuration file

Specifу the path to the application configuration file to be used when running tests. The path should be either absolute or relative to the checkout directory.

This option is available only if NUnit 3.0 is selected.

Additional command line parameters

Enter additional command line parameters to pass to nunit-console.exe.

This option is available only if NUnit 3.0 is selected.

.NET Runtime

From the Platform drop-down menu, select the desired execution mode on an x64 machine. Supported values are: Auto (MSIL), x86, and x64.

From the Version drop-down menu, select the required .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 stored. Multiple entries should be comma-separated. The MSBuild wildcards are supported. The paths to assembly files should be absolute or relative to the checkout directory.

In the example, TeamCity will search for the tests assemblies in all the project directories and run these tests:

**\*.dll

Wildcards are specified relatively 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 should be comma-separated. The MSBuild wildcards are supported. The paths to assembly files should be absolute or relative to the checkout directory.

In the example, TeamCity will omit tests specified in this directory:

**\obj\**\*.dll

Wildcards are specified relatively to the checkout directory.

Include categories

Specify NUnit categories of tests to be run. Multiple entries should be comma-separated.
Category expressions are supported 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 should be 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

Select this option if you want to run each assembly in a new process.

This option is available only for the legacy NUnit runner with NUnit versions prior to 3.0.

Reduce test failure feedback time

Use this option to instruct TeamCity to run some tests before others.

NUnit Code Coverage

To learn about configuring code coverage options, refer to the this article.

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

Last modified: 18 September 2024