TeamCity NUnit Test Launcher
TeamCity provides its own NUnit tests launcher that can be used from the command line. The tests are run according to the passed parameters and, if the process is run inside the TeamCity build agent environment, the results are reported to the TeamCity agent.
You can pass the following command line options to the TeamCity NUnit Test Launcher:
Option | Description |
---|---|
<.NET Framework> | Version of .NET Framework to run tests. Acceptable values are v1.1, v2.0, v4.0, and ANY. |
<platform> | Platform to run tests. Acceptable values are x86, x64, and MSIL. |
<NUnit vers.> | Test framework to use. The value has to be specified in the following format: NUnit-<version>. |
/category-include:<list> | The list of categories separated by " |
/category-exclude:<list> | The list of categories separated by " |
/addin:<list> | List of third-party NUnit addins to use (optional). |
<assemblies to test> | List of assemblies paths separated by " |
/runAssemblies:processPerAssembly | Specify, if you want to run each assembly in a new process. |
Category Expression
Beginning with NUnit 2.4.6 and up to but not including NUnit v3.0, a Category Expression can be used. The table shows some examples:
Expression | Action |
---|---|
A|B|C | Selects tests having any of the categories A, B or C. |
A,B,C | Selects tests having any of the categories A, B or C. |
A+B+C | Selects only tests having all three of the categories assigned. |
A+B|C | Selects tests with both A and B OR with category C. |
A+B-C | Selects tests with both A and B but not C. |
-A | Selects tests not having category A assigned. |
A+(B|C) | Selects tests having both category A and either of B or C. |
A+B,C | Selects tests having both category A and either of B or C. |
Note: As shown by the last two examples, the comma operator (,
) is equivalent to the pipe (|
) but has a higher precendence. The order of evaluation is as follows:
Unary exclusion operator (
-
)High-precendence union operator (
,
)Intersection and set subtraction operators (
+
and binary-
)Low-precedence union operator (
|
)
Note: Since the operator characters have special meaning, avoid creating a category that uses any of them in its name. For example, the category db-tests
must not be used in the command line, as it appears to mean "run category db, except for category tests". The same limitation applies to the characters having a special meaning for the shell you are using.
Examples
The following examples assume that the teamcity.dotnet.nunitlauncher
property is set as a system property on the Parameters page of the Build Configuration.
Run tests from an assembly:
Run tests from an assembly with NUnit categories filter
Run tests from assemblies: