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

About NUnit Support

Last modified: 20 April 2023

In order to support reporting NUnit tests results, TeamCity should either run the tests using its own NUnit Test Launcher or be able to interact with the .NET testing frameworks, so it receives notifications on test events. This page describes avaialble runner-specific ways of configuring NUnit testing, and the general ones that suite to any build runner:

Any Build Runner



The following ways of configuring NUnit tests reporting are available for all runners:

  • Use command line TeamCity NUnit Test Launcher: You can run your NUnit tests on the TeamCity side by launching the TeamCity NUnit Tests Launcher from command line, thus you don't need to make any modifications to your build script to be able to track the tests in TeamCity. For the configuration details refer to TeamCity NUnit Test Launcher.

  • Plug TeamCity Addin for NUnit to your NUnit framework: If you prefer to run your NUnit tests using NUnit console and another runner is not an option; TeamCity will be able to track the tests results, if you will plug TeamCity Addin for NUnit into NUnit. For the details refer to TeamCity Addin for NUnit.

  • Import xml reports: TeamCity is able of importing xml test reports by means of the bindled XML Test Reporting plugin. For the details refer to XML Reports Import.

  • Manually configure reporting NUnit tests to TeamCity: Tests reporting can be manually configured via service messages. For the details refer to Build Script Interaction with TeamCity.

MSBuild/Solution Runner



Additionally to the approaches available for anyBuildRunner, there are several ways of configuring NUnit tests that are only available, when using MSBuild runner or Visual Studio (sln) runner:

  • Configure NUnit tests in the TeamCity web UI: If you haven't yet configured NUnit tests in your build script, you can set up NUnit test options right in the TeamCity web UI, and TeamCity will do the rest, i.e. use its own test runner according to the specified options, such as test platform, test run framework, NUnit version, etc., and report the results. You do not need to configure the tests in the build script neither you need to have a test runner. For the details refer to Configuring TeamCity NUnit Launcher via Web UI.

  • Keep NUnit tests, already configured via NUnit task: If you have already defined NUnit tests within your build script via NUnit, you do not have to modify the script in order to have the test reports in TeamCity. TeamCity uses its own implementation of NUnit task compatible with NUnit task from MSBuild Community tasks project; and tracks the tests by automatically replacing the original task with its own and launching TeamCity NUnit test runner. For the details refer to NUnit for MSBuild.

  • Use TeamCity-specific task to configure NUnit tests in the build script: TeamCity provides its own NUnitTeamCity task that is compatible with the standard <NUnit> MSBuild task from the MSBuild Community tasks. Add it to the build script to pass the required options to the TeamCity launcher. For the details refer to NUnit for MSBuild.

NAnt Build



  • Keep NUnit tests, already configured via <nunit2> task: TeamCity is compatible with the standard <nunit2> task. If you already have standard <nunit2> task configured in your NAnt build script, TeamCity will replace it with its own implementation of this task and launch its own test runner in order to be able of tracking the tests results. You don't need to make any changes to your build script, although you can specify additional options to be passed to the TeamCity test launcher. For the details refer to NUnit for NAnt Build Runner. If you don't want TeamCity to replace your task, consider the approaches listed for anyBuildRunner.

For most cases TeamCity NUnit Test Launcher suits perfectly well, as it can be configured as command line runner, or in the build script, and even in the web UI. It can be launched from any runner and is compatible with standard NUnit tasks for NAnt and MSBuild. Moreover, if you run your NUnit tests using TeamCity NUnit Test Launcher, you can instruct TeamCity to run some tests before others by means of the Running Risk Group Tests First. For those, who use NUnit console there is TeamCity Addin for NUnit. Even if these approaches do not suite your case, you can use service messages, or bundled XML tests reporting plugin.