TeamCity 4.0 Help

NUnit for MSBuild

TeamCity provides custom NUnitTeamCity task and NUnit task that is compatible with NUnit task from MSBuild Community tasks project.

The NUnit/NUnitTeamCity task uses the following syntax:

<UsingTask TaskName="NUnit" AssemblyFile="$(teamcity_dotnet_nunitlauncher_msbuild_task)" />

The NUnit/NUnitTeamCity task tests .NET Assemblies with NUnit. Add the following code to your target in MSBuild script to implement it:

<NUnitTeamCity Assemblies="@(assemblies_to_test)" />

This NUnit task is automatically included in MSBuild and Solution2005 and Solution2008 builds.

The NUnitTeamCity task supports the following extra attributes:

Property name

description

Platform

Specifies the desired execution mode on a x64 machine. Supported values are: x86, x64 and ANY.

IncludeCategory

; separated list of categories

ExcludeCategory

; separated list of categories

NUnitVersion

Specifies which version of NUnit to run the tests.

Addins

Specifies a list of NUnit addins to use

HaltIfTestFailed

True to fail task is there were failed tests

Assemblies

List of assemblies to run tests with

Example usage is shown below (part of the MSBuild build script):

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <UsingTask TaskName="NUnit" AssemblyFile="$(teamcity_dotnet_nunitlauncher_msbuild_task)"/> <Target Name="SayHello"> <NUnit Assemblies="!!!*put here item group of assemblies to run tests on*!!!"/> </Target> </Project>
Last modified: 20 April 2023