TeamCity provides custom NUnitTeamCity task and NUnit task that is compatible with NUnit task from MSBuild Community tasks project.
 | In order for these tasks to work the teamcity_dotnet_nunitlauncher system property have to be accessible. Build Agents running windows should automatically detect these properties as environment variables. If you need to set them manually, see defining agent specific properties for more information. |
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.
 | TeamCity uses its own version of NUnit task for running NUnit tests. TeamCity version is compatible with the MSBuild Community Task and will issue a warning, if TeamCity does not support an attribute listed in the build script. These warnings are only for your information and will not affect the building process. |
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 |
As used in the original task |
| ExcludeCategory |
As used in the original task |
| NUnitVersion |
Specifies which version of NUnit to run the tests. Supported values are: NUnit-2.2.10 (default), NUnit-2.2.9-VSTS, NUnit-2.4.1, NUnit-2.4.6, NUnit-2.4.7. |
| Addins |
Specifies a list of NUnit addins to use |
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>
 |
- Be sure to replace "." with "_" when using properties in MSBuild scripts. That is you have to use teamcity_dotnet_nunitlauncher_msbuild_task instead of teamcity.dotnet.nunitlauncher.msbuild.task
- TeamCity also provides Solution 2005 Runner for Microsoft Visual Studio 2005 solution files. It allows you to use MSBuild-style wildcards for the assemblies to run unit tests on.
|