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 - TestcaseProviders</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>TestCaseProviders (NUnit 2.5)</h3>
|
---|
28 |
|
---|
29 | <h4>Purpose</h4>
|
---|
30 | <p>TestCaseProviders are used with parameterized tests to provide the
|
---|
31 | specific test cases that will be used in calling the test.
|
---|
32 |
|
---|
33 | <h4>Extension Point</h4>
|
---|
34 | <p>Addins use the host to access this extension point by name:
|
---|
35 |
|
---|
36 | <pre>
|
---|
37 | IExtensionPoint listeners = host.GetExtensionPoint( "ParameterProviders" );</pre>
|
---|
38 |
|
---|
39 | <h4>Interface</h4>
|
---|
40 | <p>The extension object passed to Install must implement either the
|
---|
41 | <b>ITestCaseProvider</b> or the <b>ITestCaseProvider2</b> interface:
|
---|
42 |
|
---|
43 | <pre>
|
---|
44 | public interface ITestCaseProvider
|
---|
45 | {
|
---|
46 | bool HasTestCasesFor( MethodInfo method );
|
---|
47 | IEnumerable GetTestCasesFor( MethodInfo method );
|
---|
48 | }
|
---|
49 |
|
---|
50 | public interface ITestCaseProvider2 : ITestCaseProvider
|
---|
51 | {
|
---|
52 | bool HasTestCasesFor( MethodInfo method, Test suite );
|
---|
53 | IEnumerable GetTestCasesFor( MethodInfo method, Test suite );
|
---|
54 | }
|
---|
55 | </pre>
|
---|
56 |
|
---|
57 | <p>NUnit will call <b>ITestCaseProvider2</b> if it is available. Otherwise
|
---|
58 | <b>ITestCaseProvider</b> will be used.
|
---|
59 |
|
---|
60 | <p><b>HasTestCasesFor</b> should return true if the provider is able to supply test cases
|
---|
61 | for the specified method. If a provider only wants to be used on certain types
|
---|
62 | of tests, it can examine the provided MethodInfo and the suite for which the
|
---|
63 | test is being constructed and return true or false based on what it finds.
|
---|
64 |
|
---|
65 | <p>The GetParametersFor method should return a list of individual test cases.
|
---|
66 | Each test case may be expressed as a ParameterSet, as an array of arguments
|
---|
67 | or as a custom object containing one or more of the following properties:
|
---|
68 |
|
---|
69 | <ul>
|
---|
70 | <li>Arguments
|
---|
71 | <li>RunState
|
---|
72 | <li>NotRunReason
|
---|
73 | <li>ExpectedExceptionType
|
---|
74 | <li>ExpectedExceptionName
|
---|
75 | <li>ExpectedExceptionMessage
|
---|
76 | <li>Result
|
---|
77 | <li>Description
|
---|
78 | <li>TestName
|
---|
79 | </ul>
|
---|
80 |
|
---|
81 | <p>The ParameterSet class provides all these properties and may be used
|
---|
82 | to avoid the overhead of reflecting on the properties.
|
---|
83 |
|
---|
84 | <h4>Notes:</h4>
|
---|
85 |
|
---|
86 | <ol>
|
---|
87 | <li>Most providers will delegate one of the interface implementations
|
---|
88 | to the other if they implement both.
|
---|
89 | <li>TestCaseProviders that use data from the fixture class should use
|
---|
90 | <b>ITestCaseProvider2</b> interface so that they are able to access any
|
---|
91 | arguments supplied for constructing the fixture object.
|
---|
92 | <li>Providers that acquire data from outside the fixture will usually
|
---|
93 | be able to work with <b>ITestCaseProvider</b> alone.
|
---|
94 | <li>The <b>ITestCaseProvider2</b> interface was added in the NUnit 2.5.1 release.
|
---|
95 | </ol>
|
---|
96 |
|
---|
97 |
|
---|
98 | </div>
|
---|
99 |
|
---|
100 | <!-- Submenu -->
|
---|
101 | <div id="subnav">
|
---|
102 | <ul>
|
---|
103 | <li><a href="index.html">NUnit 2.5.10</a></li>
|
---|
104 | <ul>
|
---|
105 | <li><a href="getStarted.html">Getting Started</a></li>
|
---|
106 | <li><a href="assertions.html">Assertions</a></li>
|
---|
107 | <li><a href="constraintModel.html">Constraints</a></li>
|
---|
108 | <li><a href="attributes.html">Attributes</a></li>
|
---|
109 | <li><a href="runningTests.html">Running Tests</a></li>
|
---|
110 | <li><a href="extensibility.html">Extensibility</a></li>
|
---|
111 | <ul>
|
---|
112 | <li><a href="customConstraints.html">Custom Constraints</a></li>
|
---|
113 | <li><a href="nunitAddins.html">NUnit Addins</a></li>
|
---|
114 | <ul>
|
---|
115 | <li><a href="suiteBuilders.html">SuiteBuilders</a></li>
|
---|
116 | <li><a href="testcaseBuilders.html">TestcaseBuilders</a></li>
|
---|
117 | <li><a href="testDecorators.html">TestDecorators</a></li>
|
---|
118 | <li id="current"><a href="testcaseProviders.html">TestcaseProviders</a></li>
|
---|
119 | <li><a href="datapointProviders.html">DatapointProviders</a></li>
|
---|
120 | <li><a href="eventListeners.html">EventListeners</a></li>
|
---|
121 | </ul>
|
---|
122 | <li><a href="extensionTips.html">Tips for Extenders</a></li>
|
---|
123 | </ul>
|
---|
124 | <li><a href="releaseNotes.html">Release Notes</a></li>
|
---|
125 | <li><a href="samples.html">Samples</a></li>
|
---|
126 | <li><a href="license.html">License</a></li>
|
---|
127 | </ul>
|
---|
128 | </ul>
|
---|
129 | </div>
|
---|
130 | <!-- End of Submenu -->
|
---|
131 |
|
---|
132 |
|
---|
133 | <!-- Standard Footer for NUnit.org -->
|
---|
134 | <div id="footer">
|
---|
135 | Copyright © 2010 Charlie Poole. All Rights Reserved.
|
---|
136 | </div>
|
---|
137 | <!-- End of Footer -->
|
---|
138 |
|
---|
139 | </body>
|
---|
140 | </html>
|
---|