source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/lib/NUnit/NUnit-2.5.10.11092/doc/consoleCommandLine.html@ 1146

Last change on this file since 1146 was 1146, checked in by Sam Habiel, 13 years ago

Initial Import of BMX4

File size: 15.1 KB
Line 
1<!-- saved from url=(0014)about:internet --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
2<html>
3<!-- Standard Head Part -->
4<head>
5<title>NUnit - ConsoleCommandLine</title>
6<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
7<meta http-equiv="Content-Language" content="en-US">
8<link rel="stylesheet" type="text/css" href="nunit.css">
9<link rel="shortcut icon" href="favicon.ico">
10</head>
11<!-- End Standard Head Part -->
12
13<body>
14
15<!-- Standard Header for NUnit.org -->
16<div id="header">
17 <a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a>
18 <div id="nav">
19 <a href="http://www.nunit.org">NUnit</a>
20 <a class="active" href="index.html">Documentation</a>
21 </div>
22</div>
23<!-- End of Header -->
24
25<div id="content">
26
27<h2>NUnit-Console Command Line Options</h2>
28<p>The console interface has a few additional options compared to the forms
29 interface. The command line must always specify one or more file names. The
30 console interface always creates an XML representation of the test results.
31 This file by default is called TestResult.xml and is placed in the working
32 directory.</p>
33<p><b>Note:</b> By default the nunit-console program is not added to your path. You
34 must do this manually if this is the desired behavior.</p>
35<p><b>Note:</b> Under the Windows operating system, options may be prefixed by either
36 a forward slash or a hyphen. Under Linux, a hyphen must be used. Options that
37 take values may use an equal sign, a colon or a space to separate the option
38 from its value.</p>
39<h4>Specifying an Assembly</h4>
40<p>The console program must always have an assembly or project specified. To run
41the tests contained in the nunit.tests.dll use the following command:</p>
42<pre class="programtext"> nunit-console nunit.tests.dll</pre>
43
44<p>To run the tests in nunit.tests.dll through the Visual Studio project, use:</p>
45 <pre class="programtext"> nunit-console nunit.tests.csproj</pre>
46
47<p>To run the same tests through an NUnit test project you have defined, use:</p>
48 <pre class="programtext"> nunit-console nunit.tests.nunit</pre>
49
50<h4>Specifying an Assembly and a Test to be Run</h4>
51<p>You may specify a test to be run by providing the full name of the test along
52with the containing assembly. For example to run NUnit.Tests.AssertionTests
53in the nunit.tests assembly use the following command:
54<pre class="programtext"> nunit-console /run:NUnit.Tests.AssertionTests nunit.tests.dll</pre>
55
56<p>The name of the test to be run may be that of a test case, test fixture or
57a namespace.
58
59<p>You can specify multiple tests by separating names with commas (without spaces). For example:
60<pre class="programtext"> nunit-console /run:NUnit.Tests.AssertionTests,NUnit.Tests.ConstraintTests nunit.tests.dll</pre>
61
62<p>Unlike the <b>/fixture</b> option, this option affects the running
63rather than the loading of the tests. Consequently it supports much broader use,
64including situations involving SetUpFixtures, which are not run if the class
65in question is not loaded. You should use <b>/run</b> in lieu of <b>/fixture</b>
66in most cases.
67
68<h4>Specifying an Assembly and a Fixture to be Loaded</h4>
69<p>When specifying a fixture, you must give the full name of the test fixture
70 along with the containing assembly. For example, to load the
71 NUnit.Tests.AssertionTests in the nunit.tests.dll assembly use the following
72 command:
73 <pre class="programtext"> nunit-console /fixture:NUnit.Tests.AssertionTests nunit.tests.dll</pre>
74</p>
75<p>The name specified after the <b>/fixture</b> option may be that of a TestFixture
76 class, a legacy suite (using the Suite property ) or a namespace. If a
77 namespace is given, then all fixtures under that namespace are loaded.</p>
78<p>This option is provided for backward compatibility. In most cases, you will
79be better served by using the <b>/run</b> option.
80
81<h4>Specifying the .NET Framework Version</h4>
82
83<p>Most applications are written to run under a specific version of the CLR.
84A few are designed to operate correctly under multiple versions. In either case,
85it is important to be able to specify the CLR version to be used for testing.</p>
86
87<p>Prior to version 2.5, it was necessary to run the console program itself using
88the CLR version under which you wanted to run tests. This was done either by
89editing the nunit-console.exe.config file or by setting the COMPLUS_Version
90environment variable before running the program.
91
92<p>Under NUnit 2.5 and later versions, you may still use either of these approaches,
93but a simpler method is available.
94
95<p>The <b>/framework</b> option allows you to specify the version of the runtime
96 to be used in executing tests. If that version specified is different from the
97 one being used by NUnit, the tests are run in a separate process. For example,
98 you may enter
99 <pre class="programtext"> nunit-console myassembly.dll /framework:net-1.1</pre>
100</p>
101
102<p>This command will run tests under .NET 1.1 even if you are running the .NET 2.0
103 build of the nunit-console. Beginning with version 2.5.3, all versions of .NET
104 through 4.0 as well as Mono profiles 1.0, 2.0 and 3.5 are supported.
105
106<h4>Specifying Test Categories to Include or Exclude</h4>
107<p>NUnit provides CategoryAttribute for use in marking tests as belonging to
108 one or more categories. Categories may be included or excluded in a test run
109 using the <b>/include</b> and <b>/exclude</b> options. The following command
110 runs only the tests in the BaseLine category:
111 <pre class="programtext"> nunit-console myassembly.dll /include:BaseLine</pre>
112</p>
113<p>The following command runs all tests <b>except</b> those in the Database
114 category:
115 <pre class="programtext"> nunit-console myassembly.dll /exclude:Database</pre>
116</p>
117<p>
118Multiple categories may be specified on either option, by using commas to
119separate them.
120<p><b>Notes:</b> Beginning with NUnit 2.4, the /include and /exclude options may
121 be combined on the command line. When both are used, all tests with the included
122 categories are run except for those with the excluded categories.</p>
123
124<p>Beginning with NUnit 2.4.6, you may use a <b>Category Expression</b> with either
125of these options:
126<dl>
127 <dt>A|B|C
128 <dd>Selects tests having any of the categories A, B or C.
129 <dt>A,B,C
130 <dd>Selects tests having any of the categories A, B or C.
131 <dt>A+B+C
132 <dd>Selects only tests having all three of the categories assigned
133 <dt>A+B|C
134 <dd>Selects tests with both A and B OR with category C.
135 <dt>A+B-C
136 <dd>Selects tests with both A and B but not C.
137 <dt>-A
138 <dd>Selects tests not having category A assigned
139 <dt>A+(B|C)
140 <dd>Selects tests having both category A and either of B or C
141</dl>
142<p>The comma operator is equivalent to | but has a higher precendence. Order
143of evaluation is as follows:
144<ol>
145<li>Unary exclusion operator (-)
146<li>High-precendence union operator (,)
147<li>Intersection and set subtraction operators (+ and binary -)
148<li>Low-precedence union operator (|)
149</ol>
150
151<p><b>Note:</b> Because the operator characters have special meaning,
152you should avoid creating a category that uses any of them in it's name.
153For example, the category "db-tests" could not be used on the command
154line, since it appears to means "run category db, except for category tests."
155The same limitation applies to characters that have special meaning for
156the shell you are using.
157
158<p>For a clear understanding of how category
159 selection works, review the documentation for both the
160 <a href="category.html">Category Attribute</a> and the
161 <a href="explicit.html">Explicit Attribute</a>.</p>
162<h4>Redirecting Output</h4>
163<p>Output created by the test, which is normally shown on the console, may be
164 redirected to a file. The following command redirects standard output to the
165 file TestResult.txt:
166 <pre class="programtext"> nunit-console nunit.tests.dll /out:TestResult.txt</pre>
167</p>
168<p>The following command redirects standard error output to the StdErr.txt file.
169 <pre class="programtext"> nunit-console nunit.tests.dll /err:StdErr.txt</pre>
170</p>
171
172<p><b>Note:</b>This option only redirects output produced <b>by the tests</b>,
173 together with selected NUnit output that is interspersed with the test output.
174 It does not redirect <b>all</b> console output. If you want to redirect <b>all</b>
175 output to a file, you should use command line redirection as supported by the
176 shell you are using. This option exists for the purpose of separating test
177 output from other output, such as the NUnit summary report.
178
179<h4>Labeling Test Output</h4>
180<p>The output from each test normally follows right after that of the preceding
181 test. You may use the <b>/labels</b> option to cause an identifying label to be
182 displayed at the start of each test case.</p>
183<h4>Specifying the XML file name</h4>
184<p>As stated above, the console program always creates an XML representation of the
185 test results. To change the name of the output file to
186 &quot;console-test.xml&quot; use the following command line option:
187 <pre class="programtext"> nunit-console /xml:console-test.xml nunit.tests.dll</pre>
188</p>
189<p><b>Note:</b> For additional information see the XML schema for the test results.
190 This file is in the same directory as the executable and is called
191 <a href="files/Results.xsd">Results.xsd</a>.
192
193<h4>Specifying which Configuration to run</h4>
194<p>When running tests from a Visual Studio or NUnit project, the first
195 configuration found will be loaded by default. Usually this is Debug. The
196 configuration loaded may be controlled by using the <b>/config</b> switch. The
197 following will load and run tests for the Release configuration of
198 nunit.tests.dll.
199 <pre class="programtext"> nunit-console nunit.tests.csproj /config:Release</pre>
200</p>
201<p><b>Note:</b> This option has no effect when loading an assembly directly.</p>
202<h4>Specifying Multiple Assemblies</h4>
203<p>You may run tests from multiple assemblies in one run using the console
204 interface even if you have not defined an NUnit test project file. The
205 following command would run a suite of tests contained in assembly1.dll,
206 assembly2.dll and assembly3.dll.
207 <pre class="programtext"> nunit-console assembly1.dll assembly2.dll assembly3.dll</pre>
208</p>
209<p><b>Notes:</b> You may specify multiple assemblies, but not multiple NUnit or
210 Visual Studio projects on the command line. Further, you may not specify an
211 NUnit or Visual Studio project together with a list of assemblies.</p>
212<p>Beginning with NUnit 2.4, the console loads multiple assemblies specified
213 in this way into separate AppDomains by default. You may provide a separate
214 config file for each assembly. You may override the default by use of the
215 <b>/domain</b> option.
216<p>Beginning with NUnit 2.4, the <b>/fixture</b>
217 option, when used with multiple assemblies, will run tests matching the
218 fixture name in all the assemblies. In earlier versions, only the first
219 test found was executed.</p>
220<h4>Controlling the Use of Processes</h4>
221<p>The <b>/process</b> option controls how NUnit loads tests in processes. The
222 following values are recognized.
223 <dl style="margin-left: 2em">
224 <dt><b>Single</b>
225 <dd>All the tests are run in the nunit-console process. This is the default.
226 <dt><b>Separate</b>
227 <dd>A separate process is created to run the tests.
228 <dt><b>Multiple</b>
229 <dd>A separate process is created for each test assembly, whether specified
230 on the command line or listed in an NUnit project file.
231 </dl>
232<h4>Controlling the Use of AppDomains</h4>
233<p>The <b>/domain</b> option controls of the creation of AppDomains for running tests.
234 The following values are recognized:</p>
235 <dl style="margin-left: 2em">
236 <dt><b>None</b>
237 <dd>No domain is created - the tests are run in the primary domain. This normally
238 requires copying the <b>NUnit</b> assemblies into the same directory as your tests.
239 <dt><b>Single</b>
240 <dd>A test domain is created - this is how NUnit worked prior to version 2.4
241 <dt><b>Multiple</b>
242 <dd>A separate test domain is created for each assembly
243 </dl>
244<p>The default is to use multiple domains if multiple assemblies are listed on
245 the command line. Otherwise a single domain is used.</p>
246
247<h4>Specifying a Default Timeout Value</h4>
248<p>The <b>/timeout</b> option takes an int value representing the default timeout
249to be used for test cases in this run. If any test exceeds the timeout value,
250it is cancelled and reported as an error. The default value may be overridden
251for selected tests by use of <b>TimeoutAttribute</b>.
252
253<p><b>Note:</b> If you do not use this option, no timeout is set and tests
254may run for any amount of time.
255
256<h4>Other Options</h4>
257<p>The <b>/trace</b> option allows you to control the amount of information that NUnit
258 writes to its internal trace log. Valid values are Off, Error, Warning,Info
259 and Debug. The default is Off.
260<p>The <b>/noshadow</b> option disables shadow copying of the assembly in order to
261 provide improved performance.</p>
262<p>The <b>/nothread</b> option suppresses use of a separate thread for running the
263 tests and uses the main thread instead.</p>
264<p>The <b>/wait</b> option causes the program to wait for user input before
265 exiting. This is useful when running nunit-console from a shortcut.</p>
266<p>The <b>/xmlconsole</b> option displays raw XML output on the console rather than
267 transforming it. This is useful when debugging problems with the XML format.</p>
268<p>The <b>/nologo</b> option disables display of the copyright information at the
269 start of the program.</p>
270<p>The <b>/help</b> or <b>/?</b> option displays a brief help message</p>
271
272</div>
273
274<!-- Submenu -->
275<div id="subnav">
276<ul>
277<li><a href="index.html">NUnit 2.5.10</a></li>
278<ul>
279<li><a href="getStarted.html">Getting&nbsp;Started</a></li>
280<li><a href="assertions.html">Assertions</a></li>
281<li><a href="constraintModel.html">Constraints</a></li>
282<li><a href="attributes.html">Attributes</a></li>
283<li><a href="runningTests.html">Running&nbsp;Tests</a></li>
284<ul>
285<li><a href="nunit-console.html">Console&nbsp;Runner</a></li>
286<ul>
287<li id="current"><a href="consoleCommandLine.html">Command-Line</a></li>
288</ul>
289<li><a href="nunit-gui.html">Gui&nbsp;Runner</a></li>
290<li><a href="pnunit.html">PNUnit&nbsp;Runner</a></li>
291<li><a href="nunit-agent.html">NUnit&nbsp;Agent</a></li>
292<li><a href="runtimeSelection.html">Runtime&nbsp;Selection</a></li>
293<li><a href="assemblyIsolation.html">Assembly&nbsp;Isolation</a></li>
294<li><a href="configFiles.html">Configuration&nbsp;Files</a></li>
295<li><a href="multiAssembly.html">Multiple&nbsp;Assemblies</a></li>
296<li><a href="vsSupport.html">Visual&nbsp;Studio&nbsp;Support</a></li>
297</ul>
298<li><a href="extensibility.html">Extensibility</a></li>
299<li><a href="releaseNotes.html">Release&nbsp;Notes</a></li>
300<li><a href="samples.html">Samples</a></li>
301<li><a href="license.html">License</a></li>
302</ul>
303</ul>
304</div>
305<!-- End of Submenu -->
306
307
308<!-- Standard Footer for NUnit.org -->
309<div id="footer">
310 Copyright &copy; 2010 Charlie Poole. All Rights Reserved.
311</div>
312<!-- End of Footer -->
313
314</body>
315</html>
Note: See TracBrowser for help on using the repository browser.