NAnt SDK Documentation - v0.92 |

# NUnit2Task Class

Runs tests using the NUnit V2.6 framework.

For a list of all members of this type, see NUnit2Task Members.

System.Object
NAnt.Core.Element
NAnt.Core.Task
NAnt.NUnit2.Tasks.NUnit2Task

[Visual Basic]
<TaskName(Name:="nunit2")>
Public Class NUnit2Task
Inherits Task
[C#]
[TaskName(Name="nunit2")]
public class NUnit2Task : Task

#### Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

#### Remarks

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 NUnit2Task, you must add the following node to your test config file :

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

See the NUnit home page for more information.

#### Example

Run tests in the `MyProject.Tests.dll` assembly.

    <nunit2>
        <formatter type="Plain" />
        <test assemblyname="MyProject.Tests.dll" appconfig="MyProject.Tests.dll.config" />
    </nunit2>

Only run tests that are not known to fail in files listed in the `tests.txt` file.

    <nunit2>
        <formatter type="Xml" usefile="true" extension=".xml" outputdir="${build.dir}/results" />
        <test>
            <assemblies>
                <includesfile name="tests.txt" />
            </assemblies>
            <categories>
                <exclude name="NotWorking" />
            </categories>
            <references basedir="build">
                <include name="Cegeka.Income.Services.dll" />
                <include name="Cegeka.Util.dll" />
            </references>
        </test>
    </nunit2>

#### Requirements

Namespace: NAnt.NUnit2.Tasks

Assembly: NAnt.NUnit2Tasks (in NAnt.NUnit2Tasks.dll)

#### See Also

NUnit2Task Members | NAnt.NUnit2.Tasks Namespace