Forms Interface
Console Interface
Forms Interface
The forms interface may be run with or without the name of a file
containing tests on the command line. If the program is started
without any file specified, it automatically loads the most recently
loaded assembly.
Note: Options that take values may use an equal sign, a colon
or a space to separate the option from its value.
Run without loading an Assembly
To suppress loading of the most recent assembly, use the
/noload switch:
nunit-gui /noload
Specifying an Assembly
The other option is to specify an assembly or project file name on
the command line. The following will start the forms interface
with the assembly nunit.tests.dll:
nunit-gui nunit.tests.dll
The following will start the forms interface loading the same
assembly through its Visual Studio project definition:
nunit-gui nunit.tests.csproj
Assuming an NUnit test project has been created containing the
assembly, the following will again load nunit.tests.dll:
nunit-gui nunit.tests.nunit
Specifying an Assembly and a Fixture
When specifying a a fixture, you must give the full name of the
test fixture along with the containing assembly. For example, to
load only the NUnit.Tests.AssertionTests in the
nunit.tests.dll assembly use the following command:
nunit-gui /fixture:NUnit.Tests.AssertionTests nunit.tests.dll
The name specified after the /fixture option may be that of a
TestFixture class, or a namespace. If a namespace is given, then
all fixtures under that namespace are loaded. This option may be
used with Visual Studio or NUnit projects as well.
Load and Run Tests
Normally, nunit-gui only loads an assembly and then waits for
the user to click on the Run button. If you wish to have the
tests run immediately, use the /run option:
nunit-gui nunit.tests.dll /run
Specifying which Configuration to Load
When loading a Visual Studio project or an NUnit project, the
first configuration found will be loaded by default. Usually this
is Debug. The configuration loaded may be controlled using the
/config switch. The following will load the Release configuration
of the nunit.tests.dll:
nunit-gui nunit.tests.csproj /config:Release
Note: This option has no effect when loading an assembly directly.
Specifying Multiple Assemblies
The forms interface does not currently provide for specifying
more than one assembly on the command line. Multiple-assembly
projects must be loaded by specifying the name of a Visual Studio
solution file or an NUnit test project.
Displaying Help
The /help or /? option displays a message box containing a brief
help message.
Console Interface
The console interface has a few additional options compared to the
forms interface. The command line must always specify one or more
file names. The console interface always creates an XML representation
of the test results. This file by default is called
TestResult.xml and is placed in the working directory.
Note: By default the nunit-console program is not added to your
path. You must do this manually if this is the desired behavior.
Note: Options that take values may use an equal sign, a colon
or a space to separate the option from its value.
Specifying an Assembly
The console program must always have an assembly or project specified.
To run the tests contained in the nunit.tests.dll use the
following command:
nunit-console nunit.tests.dll
To run the tests in nunit.tests.dll through the
Visual Studio project, use:
nunit-console nunit.tests.csproj
To run the same tests through an NUnit test project you have
defined, use:
nunit-console nunit.tests.nunit
Specifying an Assembly and a Fixture
When specifying a a fixture, you must give the full name of the
test fixture along with the containing assembly. For example, to
run the NUnit.Tests.AssertionTests in the
nunit.tests.dll assembly use the following command:
nunit-console /fixture:NUnit.Tests.AssertionTests nunit.tests.dll
The name specified after the /fixture option may be that of a
TestFixture class, a legacy suite (using the Suite property ) or
a namespace. If a namespace is given, then all fixtures under that
namespace are run. This option may be used with Visual Studio or NUnit
projects as well.
Specifying Test Categories to Include or Exclude
NUnit 2.2 provides CategoryAttribute for use in
marking tests as belonging to one or more categories. Categories
may be included or excluded in a test run using the /include and
/exclude options. The following command runs only the tests in
the BaseLine category:
nunit-console myassembly.dll /include:BaseLine
The following command runs all tests except those in the
Database category:
nunit-console myassembly.dll /exclude:Database
Multiple categories may be specified on either option, by
using commas to separate them.
Note:In the current release, you may choose to either
include or exclude categories in a run, but not both.
For a clear understanding of how category selection
works, review the documentation for both the
Category Attribute and the
Explicit Attribute.
Redirecting Output
The output that is normally shown on the console may be redirected
to a file. This includes output created by the test program as well
as what NUnit itself creates. The following command redirects
standard output to the TestResult.txt file:
nunit-console nunit.tests.dll /out:TestResult.txt
The following command redirects standard error output to the
StdErr.txt file.
nunit-console nunit.tests.dll /err:StdErr.txt
Labeling Test Output
The output from each test normally follows right after that of
the preceding test. You may use the /labels option to cause an
identifying label to be displayed at the start of each test case.
Specifying the XML file name
As stated above, the console program always creates an XML representation
of the test results. To change the name of the output file to
"console-test.xml"
use the following command line option:
nunit-console /xml:console-test.xml nunit.tests.dll
Specifying the Transform file
The console interface uses XSLT to transform the test results from
the XML file to what is printed to the screen when the program executes.
The console interface has a default transformation that is part
of the executable. To specify your own transformation named
"myTransform.xslt"
use the following command line option:
nunit-console /transform:myTransform.xslt nunit.tests.dll
Note: For additional information see the XML schema for the test
results. This file is in the same directory as the executable and
is called Results.xsd.
The default transform
Summary.xslt is located
in the core source directory.
Specifying which Configuration to run
When running tests from a Visual Studio or NUnit project, the first
configuration found will be loaded by default. Usually this is
Debug. The configuration loaded may be controlled by using the
/config switch. The following will load and run tests for the
Release configuration of nunit.tests.dll.
nunit-console nunit.tests.csproj /config:Release
Note: This option has no effect when loading an assembly directly.
Specifying Multiple Assemblies
You may run tests from multiple assemblies in one run using the console
interface even if you have not defined an NUnit test project file.
The following command would run a suite of tests contained in
assembly1.dll, assembly2.dll and assembly3.dll.
nunit-console assembly1.dll assembly2.dll assembly3.dll
Note: You may specify multiple assemblies, but not multiple
NUnit or Visual Studio projects on the command line. Further, you
may not specify an NUnit or Visual Studio project together with a
list of assemblies.
The /fixture option may be used with multiple
assemblies but it's more efficient to simply specify the
assembly that contains the fixture.
Other Options
The /noshadow option disables shadow copying of the assembly
in order to provide improved performance.
The /thread option causes a separate thread to be created
for running the tests. This is necessary in cases where the
tests must run in a particular type of apartment. By running
in a separate thread, the ApartmentState and ThreadPriority
settings under the element of the config file will
be honored. If not thread is created, these are ignored and the
apartment will be the same as that of the console program.
Note:The apartment state of the console program may
change from release to release, so users requiring a particular
apartment should take advantage of this setting rather than
relying on the default.
The /wait option causes the program to wait for user input
before exiting. This is useful when running nunit-console from
a shortcut.
The /xmlconsole option displays raw XML output on the console
rather than transforming it. This is useful when debugging problems
with the XML format.
The /nologo option disables display of the copyright information
at the start of the program.
The /help or /? option displays a brief help message
|