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