Skip to content
This repository was archived by the owner on Feb 16, 2018. It is now read-only.

Nunit task documentation

monoman edited this page Oct 29, 2010 · 8 revisions

NUnit Task

Run NUnit on a group of assemblies.

Parameters

The following parameters are available for the NUnit task.

Assemblies

Required ITaskItem[] input parameter.

The assemblies to test. You may specify one or more assemblies or a single project file of type .nunit or .csproj/.vbproj.

WhatToRun

Optional String input parameter.

Name of the test case, fixture or namespace to run.

ProjectConfiguration

Optional String input parameter.

Project configuration (e.g.: Debug) to load. Valid only when a project is specified (.nunit or .xxproj).

OutputXmlFile

Optional String input parameter.

Name of XML output file (Default: TestResult.xml).

ErrorOutputFile

Optional String input parameter.

File to receive test error output.

ShowLabels

Optional Boolean parameter.

Label each test in stdOut.

IncludeCategory

Optional String input parameter.

List of categories to include.

ExcludeCategory

Optional String input parameter.

List of categories to exclude.

ProcessModel

Optional String input parameter.

Process model for tests: Default, Single, Separate, Multiple

AppDomainUsage

Optional String input parameter.

AppDomain Usage for tests: Default, None, Single, Multiple

FrameworkToUse

Optional String input parameter.

Framework version to be used for tests. Ex.: net-2.0, net-3.5, mono-2.0

DisableShadowCopy

Optional Boolean parameter.

Disable shadow copy when running in separate domain

TestInNewThread

Optional Boolean input parameter.

Enable use of a separate thread for tests (Default: true).

TestCaseTimeoutInMilliseconds

Optional Int32 input parameter.

Set timeout for each test case in milliseconds.

HideDots

Optional Boolean input parameter.

Do not display progress

Force32Bit

Optional Boolean parameter.

Uses the 32bit specific runner.

ToolPath

Optional String parameter.

The path of the NUnit bin folder where are the console runners. If omitted the path where this task assembly is located is use (NUnit side-installation)

ExitCode

Optional Int32 output read-only parameter.

Specifies the exit code provided by NUnit.

WorkingDirectory

Optional String parameter.

Specifies the directory in which the NUnit runner will run.

Example

The following example uses the NUnit task to test all unit tests in this project, at the end of the build, stopping if any of them fails. It assumes the NUnit binaries are installed in the ToolPath specified. You can also have the binaries in the same directory as the task assembly (Side-Installation) and avoid having to specify the ToolPath.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
        <UsingTask AssemblyFile="..\NUnit\MSBuild.NUnit.dll" TaskName="MSBuild.Tasks.NUnit" />
        <Target Name="RunUnitTest">
            <NUnit Assemblies="$(ProjectName).csproj" 
                   ToolPath="C:\Program Files (x86)\NUnit 2.5.5\bin\net-2.0"
                   DisableShadowCopy="true" Force32Bit="false" ProjectConfiguration="$(Configuration)" FrameworkToUse="net-3.5" 
                   WorkingDirectory="$(ProjectDir)" ContinueOnError="false" />
        </Target>
        <Target Name="AfterBuild" DependsOnTargets="RunUnitTest">
        </Target>
</Project>