In today’s episode of the NUnit mini-series we’d like to share some information on using TeamCity Addin for NUnit.
As we wrote in our previous post, to provide tests state tracking and on-the-fly reporting, TeamCity bundles NUnit and includes its own NUnit runners. These embedded runners suit most cases perfectly well but there can be situations when you:
- prefer to use particular NUnit instance (not TeamCity’s bundled) for your particular build configuration
- want to pass NUnit project file (
For cases like these you can use a recently implemented TeamCity Addin for NUnit available in TeamCity 4.0 EAP; the Addin supports the following versions of NUnit: 2.4.6, 2.4.7, 2.4.8 and 2.5.0 Alpha3.
How does it work?
TeamCity Addin for NUnit is embedded in the system by default and contains
.pdb files for each supported version of NUnit. For every build, the main part of a path to the TeamCity Addin is set to the build property and the environment variable of the same name:
To enable on-the-fly tests reporting, all you have to do is to add a task in your build for copying an appropriate Addin’s files to your NUnit’s addins directory. Type your NUnit version at the end of the TeamCity Addin path using the following syntax:
- For NAnt:
- For MSBuild:
In the above filenames, the <NUnit version> parameter can possess the following values: 2.4.6, 2.4.7, 2.4.8, and 2.5.0.
Please note that we recommend to copy TeamCity Addin for NUnit files every time you run the particular build.
The following example for MSBuild shows how to use NUnit console runner with TeamCity Addin for NUnit 2.4.7:
<PropertyGroup> <NUnit>Path_to_NUnit_console</NUnit> <NUnitAddinsDir>Path_to_NUnit_Addins _Dir</NUnitAddinsDir> </PropertyGroup> <ItemGroup> <NUnitAddinFiles Include="$(teamcity_dotnet_nunitaddin)-2.4.7.*" /> </ItemGroup> <Target Name="RunTests"> <Copy SourceFiles="@(NUnitAddinFiles)" DestinationFolder="$(NUnitAddinsDir)" /> <Exec Command="$(NUnit) $(NUnitFileName)" /> </Target>
Well, it’s again a time for a break. See you soon!