TeamCity
Powerful CI/CD for DevOps-centric teams
Unfolding TeamCity Addin for NUnit Secrets
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 (
.nunit
)
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 .dll
and .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:
-
teamcity.dotnet.nunitaddin
for NAnt -
teamcity_dotnet_nunitaddin
for MSBuild
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:
${teamcity.dotnet.nunitaddin}-<NUnit version>.dll
- For MSBuild:
$(teamcity_dotnet_nunitaddin)-<NUnit version>.dll
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><i>Path_to_NUnit_console</i></NUnit> <NUnitAddinsDir><i>Path_to_NUnit_Addins _Dir</i></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!
Technorati tags: TeamCity, JetBrains, IntelliJ IDEA, Eclipse, continuous integration, build management, agile development, NUnit, MS Visual Studio 2005, MS Visual Studio 2008