TeamCity
 
You are viewing the documentation for an earlier version of TeamCity.

TeamCity Addin for NUnit

Last modified: 20 April 2023

TeamCity Addin for NUnit allows you to enable on-the-fly tests reporting from NUnit tests runner when automatic integration is not available.

TeamCity provides Addin that you can plugin into NUnit and the tests will automatically be reported to TeamCity server.

It is highly recommended to get the Addin as a part of you build. This way you may ensure that the addin version is compatible with the TeamCity agent version.

For every build, a path to TeamCity Addin for NUnit is set to the system property teamcity.dotnet.nunitaddin (for MSBuild it would be teamcity_dotnet_nunitaddin).

You need to add the version of NUnit to the end of that path (using NAnt syntax):

  • For NUnit 2.4.X use ${teamcity.dotnet.nunitaddin}-2.4.X.dll (for MSBuild: $(teamcity_dotnet_nunitaddin)-2.4.X.dll) Example for NUnit 2.4.7: NAnt: ${teamcity.dotnet.nunitaddin}-2.4.7.dll, MSBuild: $(teamcity_dotnet_nunitaddin)-2.4.7.dll

  • For NUnit 2.5.0 use ${teamcity.dotnet.nunitaddin}-2.5.0.dll (for MSBuild: $(teamcity_dotnet_nunitaddin)-2.5.0.dll)

    note

    It is strongly recommended to copy .dll and .pdb TeamCity Addin for NUnit files every time you run the particular build, because these files could be updated by TeamCity.

    warning

    NUnit 2.4.8 has the following known issue: NUnit 2.4.8 runner tries to load assembly according to created AssemblyName object, however, 'addins' folder of NUnit 2.4.8 is not included in application probe paths. Thus NUnit 2.4.8 fails to load any addin in console mode. To solve the problem we suggest you to use any of the following workarounds:

    • copy TeamCity addin assembly both to NUnit bin and bin/addins folders

    • patch NUnit-Console.exe.config to include addins to application probe paths. Add the following code into config/runtime element: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <probing privatePath="addins"/> </assemblyBinding> See original blog post on this issue http://nunit.com/blogs/?p=56

    To enable on-the-fly test reporting for NUnit, you need to copy TeamCity Addin for NUnit files to the NUnit addin directory. The following example shows how to use NUnit console runner with TeamCity Addin for NUnit 2.4.7 (on MSBuild): <ItemGroup> <NUnitAddinFiles Include="$(teamcity_dotnet_nunitaddin)-2.4.7.*" /> </ItemGroup> <Target Name="RunTests"> <MakeDir Directories="$(NUnitAddinsDir)/addins" /> <Copy SourceFiles="@(NUnitAddinFiles)" DestinationFolder="$(NUnitAddinsDir)/addins" /> <Exec Command="$(NUnit) $(NUnitFileName)" /> </Target>

    note

    In TeamCity 4.5, you may need to configure environment variables for NUnit explicitly. Specify environment variable with value reference %system.teamcity.dotnet.nunitaddin%. See 6.Properties and environment variables for details.