source: BMXNET_RPMS_dotNET_UTILITIES-BMX/branch/IHS BMX Framework/lib/NUnit/NUnit-2.5.10.11092/doc/nunitAddins.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: 8.4 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 - NunitAddins</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 Addins</h2>
28
29<p>NUnit originally identified tests in the time-honored way used in many xUnit
30test frameworks. Test classes inherited from the framework's
31TestCase class. Individual test case methods were identified by having names
32starting with "test..."</p>
33
34<p>With NUnit 2.0, we introduced the use of attributes to identify both fixtures
35and test cases. Use of attributes in this way was a natural outcome of their
36presence in .NET and gave us a way of identifying tests that was completely
37independent of both inheritance and naming conventions.</p>
38
39<p>However, by moving away from an inheritance-based mechanism we no longer
40had an easy way for others to extend NUnit's internal behavior. NUnit Addins are
41intended to fill that gap, providing an mechanism to introduce new or changed
42behavior without modifying NUnit itself.</p>
43
44<h3>Extension Points, Extensions and Addins</h3>
45
46<p>NUnit provides a number of <b>Extension Points</b>, places where it is
47possible to extend its behavior. Because NUnit works with various hosts
48and uses separate AppDomains to run tests, <b>Extension Points</b> are
49categorized into three types: Core, Client and Gui. Each of these types is
50supported by a different <b>Extension Host</b>.
51
52<p>An NUnit <b>Addin</b> provides enhanced functionality through one or more
53extensions, which it installs at identified <b>Extension Points</b>. Each
54<b>Addin</b> is characterized by the types of extensions it supplies, so that
55an <b>Extension Host</b> knows whether to invoke it.</p>
56
57<blockquote>
58<p><b>Note:</b> In the current release, only Core extensions are actually
59supported. An Addin may characterize itself as a Client or Gui extension and
60will be listed as such in the <a href="addinsDialog.html">Addins Dialog</a>,
61but no other action is taken.</p>
62</blockquote>
63
64<h3>Addin Identification, Loading and Installation</h3>
65
66<p>NUnit examines all assemblies in the <b>bin/addins</b> directory, looking
67for public classes with the <b>NUnitAddinAttribute</b> and implementing the
68<b>IAddin</b> interface. It loads all those it finds as Addins.</p>
69
70<p><b>NUnitAddinAttribute</b> supports three optional named parameters: Type,
71Name and Description. Name and Description are strings representing the name
72of the extension and a description of what it does. If no name is provided,
73the name of the class is used. Type may be any one or a combination of the
74ExtensionType enum members:
75
76<pre>
77 [Flags]
78 public enum ExtensionType
79 {
80 Core=1,
81 Client=2,
82 Gui=4
83 }
84</pre>
85
86The values may be or'ed together, allowing for future Addins that require
87extensions at multiple levels of the application. If not provided, Type
88defaults to ExtensionType.Core.</p>
89
90<p>The <b>IAddin</b> interface, which must be implemented by each Addin,
91is defined as follows:</p>
92
93<pre>
94 public interface IAddin
95 {
96 bool Install( IExtensionHost host );
97 }
98</pre>
99
100<p> The <b>Install</b> method is called by each host for which the addin has
101specified an ExtensionType. The addin should check that the necessary extension
102points are available and install itself, returning true for success or false
103for failure to install. The method will be called once for each extension
104host and - for Core extensions - each time a new test domain is loaded.</p>
105
106<p>The Install method uses the <b>IExtensionHost</b> interface to locate
107extension points. It is defined as follows:</p>
108
109<pre>
110 public interface IExtensionHost
111 {
112 IExtensionPoint[] ExtensionPoints { get; }
113 IExtensionPoint GetExtensionPoint( string name );
114 ExtensionType ExtensionTypes { get; }
115 }
116</pre>
117
118<p>The <b>ExtensionPoints</b> property returns an array of all extension points
119for those extensions that need the information. The <b>ExtensionTypes</b>
120property returns the flags for the type of extension supported by this host,
121allowing, for example, Gui extensions to only load in a Gui host.</p>
122
123<p>Most addins will only need to use the <b>GetExtensionPoint</b> method to
124get the interface to a particular extension point. The <b>IExtensionPoint</b>
125interface is defined as follows:</p>
126
127<pre>
128 public interface IExtensionPoint
129 {
130 string Name { get; }
131 IExtensionHost Host { get; }
132 void Install( object extension );
133 void Remove( object extension );
134 }
135</pre>
136
137<p>Once again, most addins will only need to use one method - the
138<b>Install</b> method in this case. This method passes an extension object
139to the <b>Extension Point</b> where it is installed. Generally, extensions
140do not need to remove themselves once installed, but the method is
141provided in any case.</p>
142
143<p>With NUnit 2.5, an additional interface, <b>IExtensionPoint2</b> is
144available. It derives from <b>IExtensionPoint</b> and also allows setting
145the priority order in which the extension will be called in comparison to
146other extensions on the same extension point. The interface is defined
147as follows:
148
149<pre>
150 public interface IExtensionPoint2 : IExtensionPoint
151 {
152 void Install( object extension, int priority );
153 }
154</pre>
155
156<p>Only extension points that use a priority scheme implement this interface.
157In general, extension points with a priority scheme will use a default value
158for priority if the Install method without a priority is called.
159
160<p>In the NUnit 2.5 release, only the <b>TestDecorators</b> extension point implements
161<b>IExtensionPoint2</b>.
162
163<h3>Extension Point Details</h3>
164
165<p>Depending on the particular extension point, the object passed will
166need to implement one or more interfaces. The following <b>ExtensionPoints</b>
167are implemented in this release of NUnit:
168
169<ul>
170 <li><a href="suiteBuilders.html">SuiteBuilders</a> <li><a href="testcaseBuilders.html">TestCaseBuilders</a> <li><a href="testDecorators.html">TestDecorators</a> <li><a href="testcaseProviders.html">TestCaseProviders</a> <li><a href="datapointProviders.html">DataPointProviders</a> <li><a href="eventListeners.html">EventListeners</a></ul></p>
171
172<p>For examples of implementing each type of extension, see the Extensibility
173samples provided with NUnit. More complete examples are available in the
174code of NUnit itself, since NUnit uses the same mechanism internally.</p>
175
176<h4>See also...</h4>
177
178<ul>
179<li><a href="extensionTips.html">Tips for Writing Extensions</a></ul>
180
181</div>
182
183<!-- Submenu -->
184<div id="subnav">
185<ul>
186<li><a href="index.html">NUnit 2.5.10</a></li>
187<ul>
188<li><a href="getStarted.html">Getting&nbsp;Started</a></li>
189<li><a href="assertions.html">Assertions</a></li>
190<li><a href="constraintModel.html">Constraints</a></li>
191<li><a href="attributes.html">Attributes</a></li>
192<li><a href="runningTests.html">Running&nbsp;Tests</a></li>
193<li><a href="extensibility.html">Extensibility</a></li>
194<ul>
195<li><a href="customConstraints.html">Custom&nbsp;Constraints</a></li>
196<li id="current"><a href="nunitAddins.html">NUnit&nbsp;Addins</a></li>
197<ul>
198<li><a href="suiteBuilders.html">SuiteBuilders</a></li>
199<li><a href="testcaseBuilders.html">TestcaseBuilders</a></li>
200<li><a href="testDecorators.html">TestDecorators</a></li>
201<li><a href="testcaseProviders.html">TestcaseProviders</a></li>
202<li><a href="datapointProviders.html">DatapointProviders</a></li>
203<li><a href="eventListeners.html">EventListeners</a></li>
204</ul>
205<li><a href="extensionTips.html">Tips&nbsp;for&nbsp;Extenders</a></li>
206</ul>
207<li><a href="releaseNotes.html">Release&nbsp;Notes</a></li>
208<li><a href="samples.html">Samples</a></li>
209<li><a href="license.html">License</a></li>
210</ul>
211</ul>
212</div>
213<!-- End of Submenu -->
214
215
216<!-- Standard Footer for NUnit.org -->
217<div id="footer">
218 Copyright &copy; 2010 Charlie Poole. All Rights Reserved.
219</div>
220<!-- End of Footer -->
221
222</body>
223</html>
Note: See TracBrowser for help on using the repository browser.