TeamCity 2017.1 Help

TeamCity Addin for NUnit

If you run NUnit tests via the 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 the TeamCity server.

Alternatively, you can opt to use the XML Report Processing build feature, or manually configure reporting tests by means of service messages.

To be able to review test results in TeamCity, do the following:

  1. In your build, set the path to the TeamCity Addin to the system property teamcity.dotnet.nunitaddin (for MSBuild it would be teamcity_dotnet_nunitaddin), and add the version of NUnit at 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.0 alpha 4, use ${teamcity.dotnet.nunitaddin}-2.5.0.dll (for MSBuild: $(teamcity_dotnet_nunitaddin)-2.5.0.dll)

  2. Copy the .dll and .pdb TeamCity addin files to the NUnit addin directory.

The following example shows how to use the NUnit console runner with the TeamCity Addin for NUnit 2.4.7 (on MSBuild):

<ItemGroup> <NUnitAddinFiles Include="$(teamcity_dotnet_nunitaddin)-2.4.7.*" /> </ItemGroup> <Target Name="RunTests"> <MakeDir Directories="$(NUnitHome)/bin/addins" /> <Copy SourceFiles="@(NUnitAddinFiles)" DestinationFolder="$(NUnitHome)/bin/addins" /> <Exec Command="$(NUnitHome)/bin/NUnit-Console.exe $(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 an assembly according to the created AssemblyName object; however, the 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 the console mode. To solve the problem, we suggest you use any of the following workarounds:

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

  • patch NUnit-Console.exe.config to include the addins to application probe paths. Add the following code into the 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 an environment variable with the value reference of %system.teamcity.dotnet.nunitaddin%. See Configuring Build Parameters for details.

Last modified: 20 April 2023