Runs tests using the NUnit V2.2 framework.

The haltonfailure attribute is only useful when more than one test suite is used, and you want to continue running other test suites although a test failed.

Set failonerror to false to ignore any errors and continue the build.

In order to run a test assembly built with NUnit 2.0 or 2.1 using <nunit2> task, you must add the following node to your test config file :

        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                <assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" /> 
                <bindingRedirect oldVersion="" newVersion="" /> 
                <bindingRedirect oldVersion="" newVersion="" /> 

See the NUnit home page for more information.


Attribute Type Description Required
haltonfailure bool Stop the test run if a test fails. The default is false. False
failonerror bool Determines if task failure stops the build, or is just reported. The default is true. False
if bool If true then the task will be executed; otherwise, skipped. The default is true. False
unless bool Opposite of if. If false then the task will be executed; otherwise, skipped. The default is false. False
verbose bool Determines whether the task should report detailed build log messages. The default is false. False

Nested Elements:


Tests to run.

Represents a test element of an <nunit2> task.


appconfigfile The application configuration file to use for the NUnit test domain. If not specified, NAnt will try to use a configuration name matching the file name of the assembly with extension ".config". False
assemblynamefile Name of the assembly to search for tests. False
haltonfailurebool Build fails on failure. The default is true. False
testnamestring Name of a specific testfixture to run. If not specified then all testfixtures are run. False
transformfilefile XSLT transform file to use when using the Plain formatter. False

Nested Elements:


Assemblies to include in test.



Assemblies to scan for missing assembly references.



Categories of test cases to include or exclude.




Formatters to output results of unit tests.

Represents the FormatterElement of the NUnit task.


typeFormatterType Type of formatter. True
extensionstring Extension to append to the output filename. False
outputdirdirectory Specifies the directory where the output file should be written to, if usefile is true. If not specified, the output file will be written to the directory where the test module is located. False
usefilebool Determines whether output should be persisted to a file. The default is false. False




Assembly: NAnt.NUnit2Tasks (0.90.3780.0)