<nunit>

Obsolete. In a future release, this task will be moved to NAntContrib. However, we strongly advise you to upgrade to NUnit 2.x.
Runs tests using the NUnit V1.0 framework.

See the NUnit home page for more information.

The NAnt.NUnit1.Tasks.NUnitTask.HaltOnFailure or NAnt.NUnit1.Tasks.NUnitTask.HaltOnError attributes are only used to stop more than one test suite to stop running. If any test suite fails a build error will be thrown. Set NAnt.Core.Task.FailOnError to false to ignore test errors and continue build.

Parameters

Attribute Type Description Required
haltonerror bool
Stops running tests when a test causes an error. The default is false.
False
haltonfailure bool
Stops running tests if a test fails (errors are considered failures as well). The default is false.
False
timeout int
Cancel the individual tests if they do not finish in the specified time (measured in milliseconds). Ignored if fork is disabled.
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 NAnt.Core.Task.IfDefined. 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

<formatter>

Formatters to output results of unit tests.

Parameters

Attribute Type Description Required
type
Type of formatter.
True
extension string
Extension to append to the output filename.
False
outputdir directory
Specifies the directory where the output file should be written to, if NAnt.NUnit.Types.FormatterElement.UseFile is true. If not specified, the output file will be written to the directory where the test module is located.
False
usefile bool
Determines whether output should be persisted to a file. The default is false.
False

<formatter>

<test>

Tests to run.

Parameters

Attribute Type Description Required
assembly string
Assembly to load the test from.
True
class string
Class name of the test.
True
appconfig string
The application configuration file to use for the NUnit test domain.
False
fork bool
Run the tests in a separate System.AppDomain.
False
haltonerror bool
Stop the build process if an error occurs during the test run.
False
haltonfailure bool
Stop the build process if a test fails (errors are considered failures as well).
False
outfile string
Base name of the test result. The full filename is determined by this attribute and the extension of formatter.
False
todir string
Directory to write the reports to.
False

<test>

Examples

Run tests in the MyProject.Tests.dll assembly.

The test results are logged in results.xml and results.txt using the NAnt.NUnit.Types.FormatterType.Xml and NAnt.NUnit.Types.FormatterType.Plain formatters, respectively.

    <nunit basedir="build" verbose="false" haltonerror="true" haltonfailure="true">
    <formatter type="Xml" />
    <formatter type="Plain" />
    <test name="MyProject.Tests.AllTests" assembly="MyProject.Tests.dll" outfile="results"/>
</nunit>

Requirements

Assembly
NAnt.NUnit1.dll
Namespace
NAnt.NUnit1.Tasks