Using TeamCity NUnit Launcher

After not so short break we are back with the next post of our .NET mini-series, and today we are going to tell you about TeamCity NUnit Launcher — a bundled NUnit test runner. In most cases, if you need to use NUnit, all you have to do is just to run it with this Launcher.

As we said in the previous post, to provide tests state tracking and on-the-fly reporting, TeamCity contains several NUnit builds (different NUnit versions) and provides NUnit Launcher to use particular NUnit build for your tests.

To start the NUnit Launcher from any TeamCity build runner, use either the teamcity.dotnet.nunitlauncher NAnt property, or the environment variable of the same name, or the teamcity_dotnet_nunitlauncher MSBuild property. These properties should have the following mandatory parameters:

  • .NET Framework version (both 1.1 and 2.0 versions are supported),
  • The platform to run tests (x86, x64, and MSIL),
  • The test framework version to use. TeamCity supports the following NUnit versions: 2.2.10, 2.4.1, 2.4.6, 2.4.7, 2.4.8, and 2.5.0 (Alpha 3)
  • List of assemblies to test

In addition to the above-mentioned parameters, you can also specify filters by tests category and NUnit addins (for NUnit 2.4 and higher). Filters by tests category allow you to control a set of tests to run, if you use tests grouping by category in your project.

You can find the detailed description of TC NUnit Launcher syntax at TeamCity reference. Here, in this post, we will just illustrate it with the example below.

The following example shows variations of TeamCity NUnit Launcher calls to run tests with NUnit.
Let’s assume, our task has the following initial conditions (all code samples below are true to these conditions):

  • You want to run the project using an MSBuild runner
  • Assemblies to test are placed into the assemblies and assemblies.lib folders
  • Tests are grouped by following categories: ‘test‘, ‘lib‘, ‘banned
  • You use the .NET Framework, version 2.0
  • Platform is x86
  • NUnit version is 2.5.0 (Alpha 3)

In the most simple case, you have to include the following lines to your MSBuild script to run tests:

For a bit more complex processing, you can filter the assemblies to test by category. For example, let’s run tests from the ‘test‘ and ‘lib‘ categories, but not from the ‘banned‘ category:

To run NUnit with addins (for our example we chose the RowTest Addin), you need to specify the full path to the addin with the proper option of NUnit Launcher:

For afters we have the sample that shows how to run each test assembly in a separated test runner process:

That would be all for today. We hope you’ve found something useful for you.

We wish you happy building!

Technorati tags: , , , , , , , , , , ,

This entry was posted in Features, FYI, How-To's, Tips&Tricks. Bookmark the permalink.

4 Responses to Using TeamCity NUnit Launcher

  1. Pingback: Websites tagged "nunit" on Postsaver

  2. David Hauser says:

    I am trying to run nunitlauncher from within MSBuild using the @@ (xml-argument-file) parameter. However, I can’t seem to find a place where it lets me specify an include category. Please help.

  3. Michael says:


    i’m using TC NUnit launcher. But i can’t seem to get the log4net output of my Tests. Is there a way to get the log4net output into the TC Full Build log?

  4. Eugene says:

    Please configure Log4Net to produce output into stderr or stdout.

Comments are closed.