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 - RequiresMTA</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 | <h3>RequiresMTAAttribute (NUnit 2.5)</h3>
|
---|
28 |
|
---|
29 | <p>The <b>RequiresMTAAttribute</b> is used on a test method, class or assembly
|
---|
30 | to specify that the tests should be run in the multi-threaded apartment.
|
---|
31 | It causes creation of a new thread if the parent test is not already running
|
---|
32 | in the MTA.
|
---|
33 |
|
---|
34 | <p><b>Note:</b> On test methods, you may also use the <b>MTAThreadAttribute</b>.
|
---|
35 | Although the runtime only recognizes this attribute on the entrypoint of
|
---|
36 | an executable assembly, many users have expected it to work on tests, so
|
---|
37 | we treat it as a synonym.
|
---|
38 |
|
---|
39 | <h4>Examples</h4>
|
---|
40 |
|
---|
41 | <div class="code">
|
---|
42 |
|
---|
43 | <pre>
|
---|
44 |
|
---|
45 | // An MTA thread will be created and used to run
|
---|
46 | // all the tests in the assembly
|
---|
47 | [assembly:RequiresMTA]
|
---|
48 |
|
---|
49 | ...
|
---|
50 |
|
---|
51 | // TestFixture requiring a separate thread
|
---|
52 | [TestFixture, RequiresMTA]
|
---|
53 | public class FixtureRequiringMTA
|
---|
54 | {
|
---|
55 | // An MTA thread will be created and all
|
---|
56 | // tests in the fixture will run on it
|
---|
57 | // unless the containing assembly is
|
---|
58 | // already running on an MTA Thread
|
---|
59 | }
|
---|
60 |
|
---|
61 | [TestFixture]
|
---|
62 | public class AnotherFixture
|
---|
63 | {
|
---|
64 | [Test, RequiresMTA]
|
---|
65 | public void TestRequiringMTA()
|
---|
66 | {
|
---|
67 | // A separate thread will be created for this test
|
---|
68 | // unless the containing fixture is already running
|
---|
69 | // in the MTA.
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 | </pre>
|
---|
74 |
|
---|
75 | </div>
|
---|
76 |
|
---|
77 | <h4>See also...</h4>
|
---|
78 | <ul>
|
---|
79 | <li><a href="requiresThread.html">RequiresThreadAttribute</a><li><a href="requiresSTA.html">RequiresSTAAttribute</a></ul>
|
---|
80 |
|
---|
81 | </div>
|
---|
82 |
|
---|
83 | <!-- Submenu -->
|
---|
84 | <div id="subnav">
|
---|
85 | <ul>
|
---|
86 | <li><a href="index.html">NUnit 2.5.10</a></li>
|
---|
87 | <ul>
|
---|
88 | <li><a href="getStarted.html">Getting Started</a></li>
|
---|
89 | <li><a href="assertions.html">Assertions</a></li>
|
---|
90 | <li><a href="constraintModel.html">Constraints</a></li>
|
---|
91 | <li><a href="attributes.html">Attributes</a></li>
|
---|
92 | <ul>
|
---|
93 | <li><a href="category.html">Category</a></li>
|
---|
94 | <li><a href="combinatorial.html">Combinatorial</a></li>
|
---|
95 | <li><a href="culture.html">Culture</a></li>
|
---|
96 | <li><a href="datapoint.html">Datapoint(s)</a></li>
|
---|
97 | <li><a href="description.html">Description</a></li>
|
---|
98 | <li><a href="exception.html">Exception</a></li>
|
---|
99 | <li><a href="explicit.html">Explicit</a></li>
|
---|
100 | <li><a href="ignore.html">Ignore</a></li>
|
---|
101 | <li><a href="maxtime.html">Maxtime</a></li>
|
---|
102 | <li><a href="pairwise.html">Pairwise</a></li>
|
---|
103 | <li><a href="platform.html">Platform</a></li>
|
---|
104 | <li><a href="property.html">Property</a></li>
|
---|
105 | <li><a href="random.html">Random</a></li>
|
---|
106 | <li><a href="range.html">Range</a></li>
|
---|
107 | <li><a href="repeat.html">Repeat</a></li>
|
---|
108 | <li><a href="requiredAddin.html">RequiredAddin</a></li>
|
---|
109 | <li id="current"><a href="requiresMTA.html">Requires MTA</a></li>
|
---|
110 | <li><a href="requiresSTA.html">Requires STA</a></li>
|
---|
111 | <li><a href="requiresThread.html">Requires Thread</a></li>
|
---|
112 | <li><a href="sequential.html">Sequential</a></li>
|
---|
113 | <li><a href="setCulture.html">SetCulture</a></li>
|
---|
114 | <li><a href="setUICulture.html">SetUICulture</a></li>
|
---|
115 | <li><a href="setup.html">Setup</a></li>
|
---|
116 | <li><a href="setupFixture.html">SetupFixture</a></li>
|
---|
117 | <li><a href="suite.html">Suite</a></li>
|
---|
118 | <li><a href="teardown.html">Teardown</a></li>
|
---|
119 | <li><a href="test.html">Test</a></li>
|
---|
120 | <li><a href="testCase.html">TestCase</a></li>
|
---|
121 | <li><a href="testCaseSource.html">TestCaseSource</a></li>
|
---|
122 | <li><a href="testFixture.html">TestFixture</a></li>
|
---|
123 | <li><a href="fixtureSetup.html">TestFixtureSetUp</a></li>
|
---|
124 | <li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li>
|
---|
125 | <li><a href="theory.html">Theory</a></li>
|
---|
126 | <li><a href="timeout.html">Timeout</a></li>
|
---|
127 | <li><a href="values.html">Values</a></li>
|
---|
128 | <li><a href="valueSource.html">ValueSource</a></li>
|
---|
129 | </ul>
|
---|
130 | <li><a href="runningTests.html">Running Tests</a></li>
|
---|
131 | <li><a href="extensibility.html">Extensibility</a></li>
|
---|
132 | <li><a href="releaseNotes.html">Release Notes</a></li>
|
---|
133 | <li><a href="samples.html">Samples</a></li>
|
---|
134 | <li><a href="license.html">License</a></li>
|
---|
135 | </ul>
|
---|
136 | </ul>
|
---|
137 | </div>
|
---|
138 | <!-- End of Submenu -->
|
---|
139 |
|
---|
140 |
|
---|
141 | <!-- Standard Footer for NUnit.org -->
|
---|
142 | <div id="footer">
|
---|
143 | Copyright © 2010 Charlie Poole. All Rights Reserved.
|
---|
144 | </div>
|
---|
145 | <!-- End of Footer -->
|
---|
146 |
|
---|
147 | </body>
|
---|
148 | </html>
|
---|