1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<!-- Standard Head Part -->
<head>
<title>NUnit - ConfigFiles</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-US">
<link rel="stylesheet" type="text/css" href="nunit.css">
<link rel="shortcut icon" href="favicon.ico">
</head>
<!-- End Standard Head Part -->
<body>
<!-- Standard Header for NUnit.org -->
<div id="header">
<a id="logo" href="http://www.nunit.org"><img src="img/logo.gif" alt="NUnit.org" title="NUnit.org"></a>
<div id="nav">
<a href="http://www.nunit.org">NUnit</a>
<a class="active" href="index.html">Documentation</a>
</div>
</div>
<!-- End of Header -->
<div id="content">
<h2>Configuration Files</h2>
<p>NUnit uses configuration files for the test runner executable either nunit-console.exe or
nunitgui.exe as well as for the tests being run. Only settings that pertain to NUnit itself should be in
the nunit-console.exe.config and nunit-gui.exe.config, while those that pertain to your own
application and tests should be in a separate configuration file.</p>
<h3>NUnit Configuration Files</h3>
<p>One main purpose of the nunit-console and nunit-gui config files is to allow
NUnit to run with various versions of the .NET framework. NUnit is built using
versions 1.1 and 2.0 of the framework. The two builds are provided as separate
downloads and either build can be made to run against other versions of the CLR.</p>
<p>As delivered, the <startup> section of each config file is commented out,
causing NUnit to run with the version of .NET used to build it. If you uncomment
the <startup> section, the entries there control the order in which alternate
framework versions are selected.</p>
<h3>Test Configuration File</h3>
<p>When a configuration file is used to provide settings or to control the environment in which a test
is run, specific naming conventions must be followed.</p>
<p>If a single assembly is being loaded, then the configuration file is given the name of the assembly
file with the config extension. For example, the configuration file used to run nunit.tests.dll must
be named nunit.tests.dll.config and located in the same directory as the dll.</p>
<p>If an NUnit project is being loaded into a single AppDomain, the configuration file uses the
name of the project file with the extension <i>changed</i> to config. For example, the project
AllTests.nunit would require a configuration file named AllTests.config, located in the same
directory as AllTests.nunit. The same rule is followed when loading Visual Studio projects or solutions.</p>
<blockquote>
<p><b>Note:</b> The above only applies if a single AppDomain is being used. If an NUnit
project is loaded using a separate AppDomain for each assembly, then the individual
configuration files for each of the assemblies are used.
</blockquote>
<p>Generally, you should be able to simply copy your application config file and rename it as
described above.</p>
<p>It is also possible to effect the behavior of NUnit by adding special sections
to the test config file. A config file using these sections might look like this:
<div class="code" style="width: 36em">
<pre>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="NUnit">
<section name="TestCaseBuilder"
type="System.Configuration.NameValueSectionHandler"/>
<section name="TestRunner"
type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<NUnit>
<TestCaseBuilder>
<add key="OldStyleTestCases" value="false" />
</TestCaseBuilder>
<TestRunner>
<add key="ApartmentState" value="MTA" />
<add key="ThreadPriority" value="Normal" />
<add key="DefaultLogThreshold" value="Error" />
</TestRunner>
</NUnit>
...
</configuration>
</pre>
</div>
<p>The entries in the above file are all
set to default values. The meaning of each setting is as follows:
<h4>OldStyleTestCases</h4>
<p>If set to "true" NUnit will recognize methods beginning
"test..." as tests. The prefix is case insensitive.
<h4>ApartmentState</h4>
<p>Sets the apartment state for the thread used to run tests.
<h4>ThreadPriority</h4>
<p>Sets the thread priority for the test thread.
<h4>DefaultLogThreshold</h4>
<p>Sets the level for logging captured by NUnit. In the
current version only log4net logging is captured, so the
level must be one that is defined by log4net.
</div>
<!-- Submenu -->
<div id="subnav">
<ul>
<li><a href="index.html">NUnit 2.4.7</a></li>
<ul>
<li><a href="getStarted.html">Getting Started</a></li>
<li><a href="assertions.html">Assertions</a></li>
<li><a href="attributes.html">Attributes</a></li>
<li><a href="nunit-console.html">Console Runner</a></li>
<li><a href="nunit-gui.html">Gui Runner</a></li>
<li><a href="features.html">Other Features</a></li>
<ul>
<li id="current"><a href="configFiles.html">Configuration Files</a></li>
<li><a href="multiAssembly.html">Multiple Assemblies</a></li>
<li><a href="vsSupport.html">Visual Studio Support</a></li>
<li><a href="extensibility.html">Extensibility</a></li>
</ul>
<li><a href="releaseNotes.html">Release Notes</a></li>
<li><a href="samples.html">Samples</a></li>
<li><a href="license.html">License</a></li>
</ul>
</ul>
</div>
<!-- End of Submenu -->
<!-- Standard Footer for NUnit.org -->
<div id="footer">
Copyright © 2008 Charlie Poole. All Rights Reserved.
</div>
<!-- End of Footer -->
</body>
</html>
|