Summary
Runs tests using the NUnit V2.6 framework.
- Assembly
- NAnt
.NUnit2 .dll - Namespace
- NAnt
.NUnit2 .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["NUnit2Task"]
class Type type-node
Syntax
[TaskName("nunit2")]
public class NUnit2Task : Task, IConditional
Examples
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>
Remarks
The NAnt.NUnit2.Tasks.NUnit2Task.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 NAnt.Core.Task.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
NAnt.NUnit2.Tasks.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.
Attributes
| Type | Description |
|---|---|
| TaskNameAttribute | Indicates that class should be treated as a task. |
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 | List |
Formatters to output results of unit tests.
|
| HaltOnFailure | bool |
Stop the test run if a test fails. The default is
false.
|
| IfDefined | bool |
If
true then the task will be executed; otherwise,
skipped. The default is true.
Inherited from Task
|
| Labels | bool |
Indicate whether or not to label the text output as the tests run.
|
| 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 | List |
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
|
| 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 |
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 |
Runs the tests and sets up the formatters.
|
| Get |
XmlNode |
Locates the XML node for the specified attribute in either the
configuration section of the extension assembly or the.project.
Inherited from Task
|
| Get |
XmlNode |
Inherited from Element
|
| GetListener |
EventListener |
Gets a new EventListener to use for the unit tests.
|
| 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 |
void |
Performs default initialization.
Inherited from Element
|
| Initialize |
Element |
Initializes the build element.
Inherited from Element
static
|
| InitializeElement |
void |
Derived classes should override to this method to provide extra
initialization and validation not covered by the base class.
Inherited from Element
|
| InitializeTask |
void |
Initializes the task.
Inherited from Task
|
| Initialize |
void |
Initializes the configuration of the task using configuration
settings retrieved from the NAnt configuration file.
Inherited from Task
|
| InitializeXml |
void |
Initializes all build attributes and child elements.
Inherited from Element
|
| IsLogEnabledFor |
bool |
Determines whether build output is enabled for the given
NAnt.Core.Level.
Inherited from Task
|
| Log |
void |
Logs a message with the given priority.
Inherited from Task
|
| Log |
void |
Logs a formatted message with the given priority.
Inherited from Task
|
