NUnit for NAnt Build Runner

Last modified: 20 April 2023

This section assumes, that you already have a NAnt build script with configured nunit2 task in it, and want TeamCity to track test reports without making any changes to the existing build script. Otherwise, consider adding NUnit build runner as one of the steps for your build configuration.

In order to track tests defined in NAnt build via standard nunt2 task, TeamCity provides custom task implementation, and automatically replaces the original <nunit2> task with its own task. Thus when the build is triggered, TeamCity starts TeamCity NUnit Test Launcher using own implementation of <nunit2>. This allows you to leave your build script without changes and receive on-the-fly test reports in the TeamCity.

TeamCity nunt2 task implementation supports additional options that can be specified either as NAnt <property> tasks in the build script, or as System Properties under Build Configuration-> Build Parameters.

The following options are supported for TeamCity <nunit2> task implementation:

TeamCity NUnit test launcher will run tests in the .NET Framework, which is specified by NAnt target framework, i.e. on .NET Framework 1.1, 2.0 or 4.0 runtime. TeamCity also supports test categories for <nunit2> task.

Examples



Start tests form a single assembly files under x64 mode on .NET 2.0.

Run all tests from category C1, but not C2.

Explicitly specify version on NUnit to run tests with. Note, that in this case, the following property should be added before nunit2 task call.