NUnitTask Class

Summary

Runs tests using the NUnit V1.0 framework.
Assembly
NAnt.NUnit1.dll
Namespace
NAnt.NUnit1.Tasks
Interfaces
Base Types
graph BT Type-->Base0["Task"] click Base0 "/api/NAnt.Core/Task" Base0-->Base1["Element"] click Base1 "/api/NAnt.Core/Element" Base1-->Base2["Object"] Type-.->Interface0["IConditional"] click Interface0 "/api/NAnt.Core/IConditional" Type["NUnitTask"] class Type type-node

Syntax

[TaskName("nunit")]
[Obsolete("In a future release, this task will be moved to NAntContrib. However, we strongly advise you to upgrade to NUnit 2.x.")]
public class NUnitTask : Task, IConditional

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>

Remarks

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.

Attributes

Type Description
TaskNameAttribute Indicates that class should be treated as a task.
ObsoleteAttribute

Properties

Name Value Summary
CustomXmlProcessing bool
Gets a value indicating whether the element is performing additional processing using the NAnt.Core.Element.XmlNode that was used to initialize the element.
Inherited from Element
FailOnError bool
Determines if task failure stops the build, or is just reported. The default is true.
Inherited from Task
FormatterElements FormatterElementCollection
Formatters to output results of unit tests.
HaltOnError bool
Stops running tests when a test causes an error. The default is false.
HaltOnFailure bool
Stops running tests if a test fails (errors are considered failures as well). The default is false.
IfDefined bool
If true then the task will be executed; otherwise, skipped. The default is true.
Inherited from Task
Location Location
Gets or sets the location in the build file where the element is defined.
Inherited from Element
LogPrefix string
The prefix used when sending messages to the log.
Inherited from Task
Name string
The name of the task.
Inherited from Task
NamespaceManager XmlNamespaceManager
Gets or sets the System.Xml.XmlNamespaceManager.
Inherited from Element
Parent Object
Gets or sets the parent of the element.
Inherited from Element
Project Project
Gets or sets the NAnt.Core.Element.Project to which this element belongs.
Inherited from Element
Properties PropertyDictionary
Gets the properties local to this NAnt.Core.Element and the NAnt.Core.Element.Project.
Inherited from Element
Tests NUnitTestCollection
Tests to run.
Threshold Level
Gets or sets the log threshold for this NAnt.Core.Task. By default the threshold of a task is NAnt.Core.Level.Debug, causing no messages to be filtered in the task itself.
Inherited from Task
Timeout int
Cancel the individual tests if they do not finish in the specified time (measured in milliseconds). Ignored if fork is disabled.
UnlessDefined bool
Opposite of NAnt.Core.Task.IfDefined. If false then the task will be executed; otherwise, skipped. The default is false.
Inherited from Task
Verbose bool
Determines whether the task should report detailed build log messages. The default is false.
Inherited from Task
XmlNode XmlNode
Gets or sets the XML node of the element.
Inherited from Element

Methods

Name Value Summary
CopyTo(Element) void
Copies all instance data of the NAnt.Core.Element to a given NAnt.Core.Element.
Inherited from Element
Execute() void
Executes the task unless it is skipped.
Inherited from Task
ExecuteTask() void
Executes the task.
GetAttributeConfigurationNode(FrameworkInfo, string) XmlNode
Locates the XML node for the specified attribute in either the configuration section of the extension assembly or the.project.
Inherited from Task
GetAttributeConfigurationNode(XmlNode, FrameworkInfo, string) XmlNode
Inherited from Element
GetLocation() Location
Retrieves the location in the build file where the element is defined.
Inherited from Element
Initialize() void
Initializes the task.
Inherited from Task
Initialize(XmlNode) void
Performs default initialization.
Inherited from Element
InitializeBuildElement(Element, XmlNode, Element, Type) Element
Initializes the build element.
Inherited from Element
static
InitializeElement(XmlNode) void
Derived classes should override to this method to provide extra initialization and validation not covered by the base class.
Inherited from Element
InitializeTask(XmlNode) void
Initializes the task.
Inherited from Task
InitializeTaskConfiguration() void
Initializes the configuration of the task using configuration settings retrieved from the NAnt configuration file.
Inherited from Task
InitializeXml(XmlNode, PropertyDictionary, FrameworkInfo) void
Initializes all build attributes and child elements.
Inherited from Element
IsLogEnabledFor(Level) bool
Determines whether build output is enabled for the given NAnt.Core.Level.
Inherited from Task
Log(Level, string) void
Logs a message with the given priority.
Inherited from Task
Log(Level, string, Object[]) void
Logs a formatted message with the given priority.
Inherited from Task