TeamCity 5.0 Help

TeamCity Addin for NUnit

If you run NUnit tests via NUnit console and want TeamCity to track the test results without having to launch the TeamCity test runner; the best solution is to use TeamCity Addin for NUnit. You can plug this addin into NUnit, and the tests will be automatically reported to TeamCity server. Alternatively, you can opt to use XML Test Reporting plugin, or manually configure reporting tests by means of service messages.

In order to be able reviewing test results in TeamCity, do the following:

  1. In your build, set a path to TeamCity Addin to the system property teamcity.dotnet.nunitaddin (for MSBuild it would be teamcity_dotnet_nunitaddin), and add the version of NUnit to the end of this path. For example:

    • 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.5 use ${teamcity.dotnet.nunitaddin}-2.5.5.dll (for MSBuild: $(teamcity_dotnet_nunitaddin)-2.5.5.dll)

  2. Copy .dll and .pdb TeamCity addin 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>

Important Notes

NUnit 2.4.8 Issue 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

Environment variables If you 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.

Last modified: 20 April 2023