TeamCity provides its own NUnit tests launcher that can be used from command line. The tests are run according to the passed parameters and, if the process is run inside the TeamCity build agent environment, the results are reported to the TeamCity agent.

Supported NUnit versions: 2.2.102.4.12.4.62.4.72.4.82.5.02.5.22.5.32.5.42.5.52.5.62.5.72.5.82.5.92.5.102.6.02.6.12.6.22.6.3. For NUnit 3.x, use the NUnit build runner since TeamCity 9.1.
It is possible to have several versions of NUnit installed on an agent machine and use any of them in a build.

  • If you need to access the path to the TeamCity NUnit launcher from some process, you can add the %system.teamcity.dotnet.nunitlauncher% environment variable.
  • Values surrounded with "%" within custom scripts in the Commandline runner are treated as TeamCity references.

You can pass the following command line options to the TeamCity NUnit Test Launcher:

${teamcity.dotnet.nunitlauncher} <.NET Framework> <platform> <NUnit vers.> [/category-include:<list>] [/category-exclude:<list>] [/addin:<list>] <assemblies to test>

Option

Description

<.NET Framework>

Version of .NET Framework to run tests. Acceptable values are v1.1, v2.0, v4.0 or ANY.

<platform>

Platform to run tests. Acceptable values are x86, x64 and MSIL.

For .NET Framework 1.1 only MSIL option is available.

<NUnit vers.>

Test framework to use. The value has to be specified in the following format: NUnit-<version>.

/category-include:<list>

The list of categories separated by ';' (optional).

/category-exclude:<list>

The list of categories separated by ';' (optional).

/addin:<list>

List of third-party NUnit addins to use (optional).

<assemblies to test>

List of assemblies paths separated by ';' or space.

/runAssemblies:processPerAssembly

Specify, if you want to run each assembly in a new process.

Examples

The following examples assume that the teamcity.dotnet.nunitlauncher property is set as system property on the Parameters page of the Build Configuration.

Run tests from an assembly:

%teamcity.dotnet.nunitlauncher% v2.0 x64 NUnit-2.2.10 Assembly.dll

Run tests from an assembly with NUnit categories filter

%teamcity.dotnet.nunitlauncher% v2.0 x64 NUnit-2.2.10 /category-include:C1 /category-exclude:C2 Assembly.dll

Run tests from assemblies:

%teamcity.dotnet.nunitlauncher% v2.0 x64 NUnit-2.5.0 /addin:Addin1.dll;Addin2.dll Assembly.dll Assebly2.dll

{show-if:action=edit}
old content
TeamCity uses its own NUnit tests launcher that can be used from any runner. The tests are run according to the passed parameters and if the process is run inside TeamCity build agent environment, the results are reported to the TeamCity agent.

The property is available as system properties of the build system (NAnt, MSTest)
{{teamcity.dotnet.nunitlauncher}} --- full launcher application name
To have this property as environment variable, please use the *Parameters* page to define build environment variable with value: %{{system.teamcity.dotnet.nunitlauncher}}%

The launcher supports the following command line options:
{code}
${teamcity.dotnet.nunitlauncher} <.NET Framework> <platform> <NUnit vers.> [/category-include:<list>] [/category-exclude:<list>] [/addin:<list>] <assemblies to test>
{code}
|| Option || Description ||
| <.NET Framework> | The version of .NET Framework to run tests. Possible values are *v1.1*, *v2.0*, *v4.0* (starting from 5.1.x) or *ANY*. |
| <platform> | The platform to run tests. Possible values: *x86*, *x64* and *MSIL*.
{note}For .NET Framework 1.1 it is only possible to use *MSIL* option.\\
 {note} |
| <NUnit vers.> | The test framework to use. Possible values are *NUnit-<version>*, where *<version>* is one of the following:
{include: SupportedNUnitVersions} |
| /category-include:<list> | The list of categories separated by *';'*. Optional parameter. |
| /category-exclude:<list> | The list of categories separated by *';'*. Optional parameter. |
| /addin:<list> | Specifies the list of used NUnit addins. Optional parameter.
{info}Addins are supported in NUnit&nbsp;2.4.x versions.\\
 {info} |
| <assemblies to test> | The list of assemblies paths separated by *';'* or space. |
{note}{*}NUnit-2.2.9-VSTS* is a modified version of NUnit&nbsp;2.2.9 to run Microsoft Visual Studio Team System Tests (for Microsoft Visual Studio 2005)
{note}
{show-if}