nunit 2.4.8.0 → 2.5.0.9122
Sign up to get free protection for your applications and to get access to all the features.
- data/docs/addinsDialog.html +36 -6
- data/docs/assertions.html +31 -12
- data/docs/attributes.html +59 -36
- data/docs/category.html +32 -9
- data/docs/collectionAssert.html +30 -12
- data/docs/collectionConstraints.html +242 -44
- data/docs/combinatorial.html +130 -0
- data/docs/comparisonAsserts.html +12 -9
- data/docs/comparisonConstraints.html +159 -25
- data/docs/compoundConstraints.html +12 -9
- data/docs/conditionAsserts.html +36 -12
- data/docs/conditionConstraints.html +131 -25
- data/docs/configEditor.html +10 -5
- data/docs/configFiles.html +5 -6
- data/docs/consoleCommandLine.html +51 -24
- data/docs/constraintModel.html +56 -19
- data/docs/contextMenu.html +10 -5
- data/docs/culture.html +32 -9
- data/docs/customConstraints.html +53 -37
- data/docs/datapoint.html +124 -0
- data/docs/datapointProviders.html +105 -0
- data/docs/delayedConstraint.html +98 -0
- data/docs/description.html +32 -9
- data/docs/directoryAssert.html +151 -0
- data/docs/equalConstraint.html +167 -47
- data/docs/equalityAsserts.html +12 -9
- data/docs/eventListeners.html +110 -0
- data/docs/exception.html +61 -36
- data/docs/exceptionAsserts.html +210 -0
- data/docs/explicit.html +32 -9
- data/docs/extensibility.html +8 -8
- data/docs/extensionTips.html +100 -0
- data/docs/fileAssert.html +12 -9
- data/docs/files/TestResult.xml +99 -67
- data/docs/fixtureSetup.html +60 -18
- data/docs/fixtureTeardown.html +56 -17
- data/docs/getStarted.html +9 -4
- data/docs/guiCommandLine.html +10 -5
- data/docs/identityAsserts.html +12 -9
- data/docs/ignore.html +32 -9
- data/docs/img/addinsDialog.JPG +0 -0
- data/docs/img/advancedSettings.jpg +0 -0
- data/docs/img/assembliesTab.jpg +0 -0
- data/docs/img/assemblyReloadSettings.JPG +0 -0
- data/docs/img/configEditor.jpg +0 -0
- data/docs/img/console-mock.jpg +0 -0
- data/docs/img/generalSettings.jpg +0 -0
- data/docs/img/generalTab.jpg +0 -0
- data/docs/img/gui-screenshot.jpg +0 -0
- data/docs/img/gui-verify.jpg +0 -0
- data/docs/img/miniGui.jpg +0 -0
- data/docs/img/testLoadSettings.jpg +0 -0
- data/docs/img/testOutputSettings.jpg +0 -0
- data/docs/img/testProperties.jpg +0 -0
- data/docs/img/testResultSettings.JPG +0 -0
- data/docs/img/textOutputSettings.jpg +0 -0
- data/docs/img/treeDisplaySettings.jpg +0 -0
- data/docs/img/visualStudioSettings.jpg +0 -0
- data/docs/index.html +15 -8
- data/docs/installation.html +33 -75
- data/docs/license.html +9 -4
- data/docs/listMapper.html +12 -9
- data/docs/mainMenu.html +18 -8
- data/docs/maxtime.html +109 -0
- data/docs/multiAssembly.html +5 -6
- data/docs/nunit-console.html +9 -4
- data/docs/nunit-gui.html +32 -15
- data/docs/nunit.css +3 -3
- data/docs/nunitAddins.html +41 -144
- data/docs/pairwise.html +114 -0
- data/docs/parameterizedTests.html +141 -0
- data/docs/pathConstraints.html +162 -0
- data/docs/platform.html +37 -9
- data/docs/pnunit.html +93 -0
- data/docs/projectEditor.html +82 -11
- data/docs/property.html +39 -10
- data/docs/propertyConstraint.html +12 -9
- data/docs/quickStart.html +9 -4
- data/docs/random.html +138 -0
- data/docs/range.html +149 -0
- data/docs/releaseDetail.html +861 -0
- data/docs/releaseNotes.html +457 -1133
- data/docs/repeat.html +104 -0
- data/docs/requiredAddin.html +153 -0
- data/docs/requiresMTA.html +152 -0
- data/docs/requiresSTA.html +153 -0
- data/docs/requiresThread.html +153 -0
- data/docs/sameasConstraint.html +23 -17
- data/docs/samples.html +12 -9
- data/docs/sequential.html +132 -0
- data/docs/setCulture.html +32 -9
- data/docs/{optionsDialog.html → settingsDialog.html} +89 -53
- data/docs/setup.html +61 -16
- data/docs/setupFixture.html +32 -9
- data/docs/stringAssert.html +15 -12
- data/docs/stringConstraints.html +12 -9
- data/docs/suite.html +32 -11
- data/docs/suiteBuilders.html +106 -0
- data/docs/teardown.html +56 -16
- data/docs/test.html +67 -18
- data/docs/testCase.html +168 -0
- data/docs/testCaseSource.html +284 -0
- data/docs/testDecorators.html +117 -0
- data/docs/testFixture.html +228 -16
- data/docs/testProperties.html +10 -5
- data/docs/testcaseBuilders.html +117 -0
- data/docs/testcaseProviders.html +122 -0
- data/docs/theory.html +208 -0
- data/docs/throwsConstraint.html +112 -0
- data/docs/timeout.html +109 -0
- data/docs/typeAsserts.html +47 -14
- data/docs/typeConstraints.html +12 -9
- data/docs/upgrade.html +23 -17
- data/docs/utilityAsserts.html +38 -16
- data/docs/valueSource.html +137 -0
- data/docs/values.html +136 -0
- data/docs/vsSupport.html +5 -6
- data/lib/net-1.1/NUnitTests.config +2 -2
- data/lib/net-1.1/NUnitTests.nunit +8 -11
- data/lib/net-1.1/agent.conf +4 -0
- data/lib/net-1.1/agent.log.conf +18 -0
- data/lib/net-1.1/framework/nunit.framework.dll +0 -0
- data/lib/net-1.1/framework/nunit.framework.xml +9321 -0
- data/lib/net-1.1/framework/nunit.mocks.dll +0 -0
- data/lib/net-1.1/framework/pnunit.framework.dll +0 -0
- data/lib/net-1.1/launcher.log.conf +18 -0
- data/lib/net-1.1/{fit.dll → lib/fit.dll} +0 -0
- data/lib/net-1.1/lib/log4net.dll +0 -0
- data/lib/net-1.1/lib/nunit-console-runner.dll +0 -0
- data/lib/net-1.1/lib/nunit.core.dll +0 -0
- data/lib/net-1.1/lib/nunit.core.interfaces.dll +0 -0
- data/lib/net-1.1/lib/nunit.fixtures.dll +0 -0
- data/lib/net-1.1/lib/nunit.util.dll +0 -0
- data/lib/net-1.1/nunit-agent.exe +0 -0
- data/lib/net-1.1/{nunit.exe.config → nunit-agent.exe.config} +21 -55
- data/lib/net-1.1/nunit-console.exe +0 -0
- data/lib/net-1.1/nunit-console.exe.config +19 -49
- data/lib/net-1.1/nunit.framework.dll +0 -0
- data/lib/net-1.1/pnunit-agent.exe +0 -0
- data/lib/net-1.1/pnunit-agent.exe.config +87 -0
- data/lib/net-1.1/pnunit-launcher.exe +0 -0
- data/lib/net-1.1/pnunit-launcher.exe.config +87 -0
- data/lib/net-1.1/pnunit.framework.dll +0 -0
- data/lib/net-1.1/pnunit.tests.dll +0 -0
- data/lib/net-1.1/runpnunit.bat +2 -0
- data/lib/net-1.1/test.conf +24 -0
- data/lib/net-1.1/{loadtest-assembly.dll → tests/loadtest-assembly.dll} +0 -0
- data/lib/net-1.1/tests/mock-assembly.dll +0 -0
- data/lib/net-1.1/tests/nonamespace-assembly.dll +0 -0
- data/lib/net-1.1/tests/nunit-console.tests.dll +0 -0
- data/lib/net-1.1/tests/nunit.core.tests.dll +0 -0
- data/lib/net-1.1/tests/nunit.fixtures.tests.dll +0 -0
- data/lib/net-1.1/tests/nunit.framework.dll +0 -0
- data/lib/net-1.1/tests/nunit.framework.tests.dll +0 -0
- data/lib/net-1.1/tests/nunit.mocks.tests.dll +0 -0
- data/lib/net-1.1/{nunit.util.tests.dll → tests/nunit.util.tests.dll} +0 -0
- data/lib/net-1.1/tests/test-assembly.dll +0 -0
- data/lib/net-1.1/tests/test-utilities.dll +0 -0
- data/lib/net-1.1/tests/timing-tests.dll +0 -0
- data/lib/net-2.0/NUnitTests.config +2 -2
- data/lib/net-2.0/NUnitTests.nunit +11 -11
- data/lib/net-2.0/agent.conf +4 -0
- data/lib/net-2.0/agent.log.conf +18 -0
- data/lib/net-2.0/framework/nunit.framework.dll +0 -0
- data/lib/net-2.0/framework/nunit.framework.xml +9803 -0
- data/lib/net-2.0/framework/nunit.mocks.dll +0 -0
- data/lib/net-2.0/framework/pnunit.framework.dll +0 -0
- data/lib/net-2.0/launcher.log.conf +18 -0
- data/lib/{net-1.1 → net-2.0/lib}/Failure.jpg +0 -0
- data/lib/net-2.0/{Success.jpg → lib/Gray.jpg} +0 -0
- data/lib/{net-1.1 → net-2.0/lib}/Ignored.jpg +0 -0
- data/lib/{net-1.1 → net-2.0/lib}/Success.jpg +0 -0
- data/lib/net-2.0/{fit.dll → lib/fit.dll} +0 -0
- data/lib/net-2.0/lib/log4net.dll +0 -0
- data/lib/net-2.0/lib/nunit-console-runner.dll +0 -0
- data/lib/net-2.0/lib/nunit-gui-runner.dll +0 -0
- data/lib/net-2.0/lib/nunit.core.dll +0 -0
- data/lib/net-2.0/lib/nunit.core.interfaces.dll +0 -0
- data/lib/net-2.0/lib/nunit.fixtures.dll +0 -0
- data/lib/net-2.0/lib/nunit.uiexception.dll +0 -0
- data/lib/net-2.0/lib/nunit.uikit.dll +0 -0
- data/lib/net-2.0/lib/nunit.util.dll +0 -0
- data/lib/net-2.0/nunit-agent.exe +0 -0
- data/lib/net-2.0/nunit-agent.exe.config +87 -0
- data/lib/net-2.0/nunit-console-x86.exe +0 -0
- data/lib/net-2.0/nunit-console-x86.exe.config +19 -49
- data/lib/net-2.0/nunit-console.exe +0 -0
- data/lib/net-2.0/nunit-console.exe.config +19 -49
- data/lib/net-2.0/nunit-x86.exe +0 -0
- data/lib/net-2.0/nunit-x86.exe.config +48 -74
- data/lib/net-2.0/nunit.exe +0 -0
- data/lib/net-2.0/nunit.exe.config +48 -74
- data/lib/net-2.0/nunit.framework.dll +0 -0
- data/lib/net-2.0/pnunit-agent.exe +0 -0
- data/lib/net-2.0/pnunit-agent.exe.config +87 -0
- data/lib/net-2.0/pnunit-launcher.exe +0 -0
- data/lib/net-2.0/pnunit-launcher.exe.config +87 -0
- data/lib/net-2.0/pnunit.framework.dll +0 -0
- data/lib/net-2.0/pnunit.tests.dll +0 -0
- data/lib/net-2.0/runpnunit.bat +2 -0
- data/lib/net-2.0/test.conf +24 -0
- data/lib/net-2.0/{loadtest-assembly.dll → tests/loadtest-assembly.dll} +0 -0
- data/lib/net-2.0/tests/mock-assembly.dll +0 -0
- data/lib/net-2.0/tests/nonamespace-assembly.dll +0 -0
- data/lib/net-2.0/tests/nunit-console.tests.dll +0 -0
- data/lib/net-2.0/tests/nunit-gui.tests.dll +0 -0
- data/lib/net-2.0/tests/nunit.core.tests.dll +0 -0
- data/lib/net-2.0/tests/nunit.fixtures.tests.dll +0 -0
- data/lib/net-2.0/tests/nunit.framework.dll +0 -0
- data/lib/net-2.0/tests/nunit.framework.tests.dll +0 -0
- data/lib/net-2.0/tests/nunit.mocks.tests.dll +0 -0
- data/lib/net-2.0/tests/nunit.uiexception.tests.dll +0 -0
- data/lib/net-2.0/tests/nunit.uikit.tests.dll +0 -0
- data/lib/net-2.0/{nunit.util.tests.dll → tests/nunit.util.tests.dll} +0 -0
- data/lib/net-2.0/tests/test-assembly.dll +0 -0
- data/lib/net-2.0/tests/test-utilities.dll +0 -0
- data/lib/net-2.0/tests/timing-tests.dll +0 -0
- metadata +131 -74
- data/docs/classicModel.html +0 -92
- data/docs/customAsserts.html +0 -115
- data/docs/features.html +0 -75
- data/docs/files/Thumbs.db +0 -0
- data/docs/platformSupport.html +0 -99
- data/lib/net-1.1/mock-assembly.dll +0 -0
- data/lib/net-1.1/nonamespace-assembly.dll +0 -0
- data/lib/net-1.1/notestfixtures-assembly.dll +0 -0
- data/lib/net-1.1/nunit-console-runner.dll +0 -0
- data/lib/net-1.1/nunit-console.tests.dll +0 -0
- data/lib/net-1.1/nunit-gui-runner.dll +0 -0
- data/lib/net-1.1/nunit-gui.tests.dll +0 -0
- data/lib/net-1.1/nunit.core.dll +0 -0
- data/lib/net-1.1/nunit.core.extensions.dll +0 -0
- data/lib/net-1.1/nunit.core.interfaces.dll +0 -0
- data/lib/net-1.1/nunit.core.tests.dll +0 -0
- data/lib/net-1.1/nunit.exe +0 -0
- data/lib/net-1.1/nunit.extensions.tests.dll +0 -0
- data/lib/net-1.1/nunit.fixtures.dll +0 -0
- data/lib/net-1.1/nunit.fixtures.tests.dll +0 -0
- data/lib/net-1.1/nunit.framework.extensions.dll +0 -0
- data/lib/net-1.1/nunit.framework.tests.dll +0 -0
- data/lib/net-1.1/nunit.framework.xml +0 -5622
- data/lib/net-1.1/nunit.mocks.dll +0 -0
- data/lib/net-1.1/nunit.mocks.tests.dll +0 -0
- data/lib/net-1.1/nunit.uikit.dll +0 -0
- data/lib/net-1.1/nunit.uikit.tests.dll +0 -0
- data/lib/net-1.1/nunit.util.dll +0 -0
- data/lib/net-1.1/test-assembly.dll +0 -0
- data/lib/net-1.1/test-utilities.dll +0 -0
- data/lib/net-1.1/timing-tests.dll +0 -0
- data/lib/net-2.0/Failure.jpg +0 -0
- data/lib/net-2.0/Ignored.jpg +0 -0
- data/lib/net-2.0/mock-assembly.dll +0 -0
- data/lib/net-2.0/nonamespace-assembly.dll +0 -0
- data/lib/net-2.0/notestfixtures-assembly.dll +0 -0
- data/lib/net-2.0/nunit-console-runner.dll +0 -0
- data/lib/net-2.0/nunit-console.tests.dll +0 -0
- data/lib/net-2.0/nunit-gui-runner.dll +0 -0
- data/lib/net-2.0/nunit-gui.tests.dll +0 -0
- data/lib/net-2.0/nunit.core.dll +0 -0
- data/lib/net-2.0/nunit.core.extensions.dll +0 -0
- data/lib/net-2.0/nunit.core.interfaces.dll +0 -0
- data/lib/net-2.0/nunit.core.tests.dll +0 -0
- data/lib/net-2.0/nunit.extensions.tests.dll +0 -0
- data/lib/net-2.0/nunit.fixtures.dll +0 -0
- data/lib/net-2.0/nunit.fixtures.tests.dll +0 -0
- data/lib/net-2.0/nunit.framework.extensions.dll +0 -0
- data/lib/net-2.0/nunit.framework.tests.dll +0 -0
- data/lib/net-2.0/nunit.framework.xml +0 -5622
- data/lib/net-2.0/nunit.mocks.dll +0 -0
- data/lib/net-2.0/nunit.mocks.tests.dll +0 -0
- data/lib/net-2.0/nunit.uikit.dll +0 -0
- data/lib/net-2.0/nunit.uikit.tests.dll +0 -0
- data/lib/net-2.0/nunit.util.dll +0 -0
- data/lib/net-2.0/test-assembly.dll +0 -0
- data/lib/net-2.0/test-utilities.dll +0 -0
- data/lib/net-2.0/timing-tests.dll +0 -0
data/docs/testCase.html
ADDED
@@ -0,0 +1,168 @@
|
|
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 - TestCase</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
|
+
<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE -->
|
28
|
+
|
29
|
+
<h3>TestCaseAttribute (NUnit 2.5)</h3>
|
30
|
+
|
31
|
+
<p><b>TestCaseAttribute</b> serves the dual purpose of marking a method with
|
32
|
+
parameters as a test method and providing inline data to be used when
|
33
|
+
invoking that method. Here is an example of a test being run three
|
34
|
+
times, with three different sets of data:
|
35
|
+
|
36
|
+
<div class="code">
|
37
|
+
<pre>[TestCase(12,3,4)]
|
38
|
+
[TestCase(12,2,6)]
|
39
|
+
[TestCase(12,4,3)]
|
40
|
+
public void DivideTest(int n, int d, int q)
|
41
|
+
{
|
42
|
+
Assert.AreEqual( q, n / d );
|
43
|
+
}
|
44
|
+
</pre>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<p><b>Note:</b> Because arguments to .NET attributes are limited in terms of the
|
48
|
+
Types that may be used, NUnit will make some attempt to convert the supplied
|
49
|
+
values using <b>Convert.ChangeType()</b> before supplying it to the test.
|
50
|
+
|
51
|
+
<p><b>TestCaseAttribute</b> may appear one or more times on a test method,
|
52
|
+
which may also carry other attributes providing test data, such as the
|
53
|
+
<a href="factories.html">FactoriesAttribute</a>.
|
54
|
+
The method may optionally be marked with the
|
55
|
+
<a href="test.html">TestAttribute</a> as well.
|
56
|
+
|
57
|
+
<p>By using the named parameter <b>Result</b> this test set may be simplified
|
58
|
+
further:
|
59
|
+
|
60
|
+
<div class="code">
|
61
|
+
<pre>[TestCase(12,3, Result=4)]
|
62
|
+
[TestCase(12,2, Result=6)]
|
63
|
+
[TestCase(12,4, Result=3)]
|
64
|
+
public int DivideTest(int n, int d)
|
65
|
+
{
|
66
|
+
return( n / d );
|
67
|
+
}
|
68
|
+
</pre>
|
69
|
+
</div>
|
70
|
+
|
71
|
+
<p>In the above example, NUnit checks that the return
|
72
|
+
value of the method is equal to the expected result provided on the attribut
|
73
|
+
|
74
|
+
<p><b>TestCaseAttribute</b> supports a number of additional
|
75
|
+
named parameters, which may be used as follows:
|
76
|
+
|
77
|
+
<dl>
|
78
|
+
<dt><b>Description</b>
|
79
|
+
<dd>Sets the description property of the test
|
80
|
+
<dt><b>ExpectedException</b>
|
81
|
+
<dd>Specifies a the Type of an exception that should be thrown by this invocation
|
82
|
+
<dt><b>ExpectedExceptionName</b>
|
83
|
+
<dd>Specifies a the FullName of an exception that should be thrown by this invocation
|
84
|
+
<dt><b>ExpectedMessage</b>
|
85
|
+
<dd>Specifies the message text of the expected exception
|
86
|
+
<dt><b>MatchType</b>
|
87
|
+
<dd>A <b>MessageMatch</b> enum value indicating how to test the expected message
|
88
|
+
(See <a href="exception.html">ExpectedExceptionAttribute</a>)
|
89
|
+
<dt><b>Result</b>
|
90
|
+
<dd>The expected result to be returned from the method, which must have
|
91
|
+
a compatible return type.
|
92
|
+
<dt><b>TestName</b>
|
93
|
+
<dd>Provides a name for the test. If not specified, a name is generated based on
|
94
|
+
the method name and the arguments provided
|
95
|
+
</dl>
|
96
|
+
|
97
|
+
</div>
|
98
|
+
|
99
|
+
<!-- Submenu -->
|
100
|
+
<div id="subnav">
|
101
|
+
<ul>
|
102
|
+
<li><a href="index.html">NUnit 2.5</a></li>
|
103
|
+
<ul>
|
104
|
+
<li><a href="getStarted.html">Getting Started</a></li>
|
105
|
+
<li><a href="assertions.html">Assertions</a></li>
|
106
|
+
<li><a href="constraintModel.html">Constraints</a></li>
|
107
|
+
<li><a href="attributes.html">Attributes</a></li>
|
108
|
+
<ul>
|
109
|
+
<li><a href="category.html">Category</a></li>
|
110
|
+
<li><a href="combinatorial.html">Combinatorial</a></li>
|
111
|
+
<li><a href="culture.html">Culture</a></li>
|
112
|
+
<li><a href="datapoint.html">Datapoint(s)</a></li>
|
113
|
+
<li><a href="description.html">Description</a></li>
|
114
|
+
<li><a href="exception.html">Exception</a></li>
|
115
|
+
<li><a href="explicit.html">Explicit</a></li>
|
116
|
+
<li><a href="ignore.html">Ignore</a></li>
|
117
|
+
<li><a href="maxtime.html">Maxtime</a></li>
|
118
|
+
<li><a href="pairwise.html">Pairwise</a></li>
|
119
|
+
<li><a href="platform.html">Platform</a></li>
|
120
|
+
<li><a href="property.html">Property</a></li>
|
121
|
+
<li><a href="random.html">Random</a></li>
|
122
|
+
<li><a href="range.html">Range</a></li>
|
123
|
+
<li><a href="repeat.html">Repeat</a></li>
|
124
|
+
<li><a href="requiredAddin.html">RequiredAddin</a></li>
|
125
|
+
<li><a href="requiresMTA.html">Requires MTA</a></li>
|
126
|
+
<li><a href="requiresSTA.html">Requires STA</a></li>
|
127
|
+
<li><a href="requiresThread.html">Requires Thread</a></li>
|
128
|
+
<li><a href="sequential.html">Sequential</a></li>
|
129
|
+
<li><a href="setCulture.html">SetCulture</a></li>
|
130
|
+
<li><a href="setup.html">Setup</a></li>
|
131
|
+
<li><a href="setupFixture.html">SetupFixture</a></li>
|
132
|
+
<li><a href="suite.html">Suite</a></li>
|
133
|
+
<li><a href="teardown.html">Teardown</a></li>
|
134
|
+
<li><a href="test.html">Test</a></li>
|
135
|
+
<li id="current"><a href="testCase.html">TestCase</a></li>
|
136
|
+
<li><a href="testCaseSource.html">TestCaseSource</a></li>
|
137
|
+
<li><a href="testFixture.html">TestFixture</a></li>
|
138
|
+
<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li>
|
139
|
+
<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li>
|
140
|
+
<li><a href="theory.html">Theory</a></li>
|
141
|
+
<li><a href="timeout.html">Timeout</a></li>
|
142
|
+
<li><a href="values.html">Values</a></li>
|
143
|
+
<li><a href="valueSource.html">ValueSource</a></li>
|
144
|
+
</ul>
|
145
|
+
<li><a href="nunit-console.html">Console Runner</a></li>
|
146
|
+
<li><a href="nunit-gui.html">Gui Runner</a></li>
|
147
|
+
<li><a href="configFiles.html">Configuration Files</a></li>
|
148
|
+
<li><a href="pnunit.html">PNUnit</a></li>
|
149
|
+
<li><a href="multiAssembly.html">Multiple Assemblies</a></li>
|
150
|
+
<li><a href="vsSupport.html">Visual Studio Support</a></li>
|
151
|
+
<li><a href="extensibility.html">Extensibility</a></li>
|
152
|
+
<li><a href="releaseNotes.html">Release Notes</a></li>
|
153
|
+
<li><a href="samples.html">Samples</a></li>
|
154
|
+
<li><a href="license.html">License</a></li>
|
155
|
+
</ul>
|
156
|
+
</ul>
|
157
|
+
</div>
|
158
|
+
<!-- End of Submenu -->
|
159
|
+
|
160
|
+
|
161
|
+
<!-- Standard Footer for NUnit.org -->
|
162
|
+
<div id="footer">
|
163
|
+
Copyright © 2009 Charlie Poole. All Rights Reserved.
|
164
|
+
</div>
|
165
|
+
<!-- End of Footer -->
|
166
|
+
|
167
|
+
</body>
|
168
|
+
</html>
|
@@ -0,0 +1,284 @@
|
|
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 - TestCaseSource</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
|
+
<script language="JavaScript" src="codeFuncs.js" ></script> <!-- Do it this way for IE -->
|
28
|
+
|
29
|
+
<h3>TestCaseSourceAttribute (NUnit 2.5)</h3>
|
30
|
+
|
31
|
+
<p><b>TestCaseSourceAttribute</b> is used on a parameterized test method to
|
32
|
+
identify the property, method or field that will provide the required
|
33
|
+
arguments. The attribute has two public constructors.
|
34
|
+
|
35
|
+
<div class="code">
|
36
|
+
<pre>
|
37
|
+
TestCaseSourceAttribute(Type sourceType, string sourceName);
|
38
|
+
TestCaseSourceAttribute(string sourceName);
|
39
|
+
</pre>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<p>If <b>sourceType</b> is specified, it represents the class that provides
|
43
|
+
the test cases. If not, the class containing the test method is used.
|
44
|
+
|
45
|
+
<p>The <b>sourceName</b> argument represents the name of the source used
|
46
|
+
to provide test cases. It has the following characteristics:
|
47
|
+
<ul>
|
48
|
+
<li>It may be a field, property or method.
|
49
|
+
<li>It may be either an instance or a static member.
|
50
|
+
<li>It must return an IEnumerable or a type that implements IEnumerable.
|
51
|
+
<li>The individual items returned by the enumerator must be compatible
|
52
|
+
with the signature of the method on which the attribute appears.
|
53
|
+
The rules for this are described in the next section.
|
54
|
+
</ul>
|
55
|
+
|
56
|
+
<h4>Constructing Test Cases</h4>
|
57
|
+
<p>In constructing tests, NUnit uses each item test case returned by
|
58
|
+
the enumerator as follows:
|
59
|
+
<ol>
|
60
|
+
<li><p>If it is an <b>object[]</b>, it is used directly to provide
|
61
|
+
the arguments for the method, as in this example, which returns
|
62
|
+
arguments from a named static field.
|
63
|
+
|
64
|
+
<div class="code">
|
65
|
+
<pre>[Test, TestCaseSource("DivideCases")]
|
66
|
+
public void DivideTest(int n, int d, int q)
|
67
|
+
{
|
68
|
+
Assert.AreEqual( q, n / d );
|
69
|
+
}
|
70
|
+
|
71
|
+
static object[] DivideCases =
|
72
|
+
{
|
73
|
+
new object[] { 12, 3, 4 },
|
74
|
+
new object[] { 12, 2, 6 },
|
75
|
+
new object[] { 12, 4, 3 }
|
76
|
+
};
|
77
|
+
</pre></div>
|
78
|
+
|
79
|
+
<li><p>If it is an array of some other type, NUnit can use it provided
|
80
|
+
that the arguments to the method are all of that type. For example,
|
81
|
+
the above code could be modified to make the three nested arrays
|
82
|
+
of type int[].
|
83
|
+
|
84
|
+
<li><p>If it is a single value type - like numerics or DateTime - it
|
85
|
+
is used directly as the sole argument to the method. The method must,
|
86
|
+
of course take a single argument of the same type for this to work.
|
87
|
+
This eliminates a bit of syntax on the part of the programmer, as in
|
88
|
+
this example:
|
89
|
+
|
90
|
+
<div class="code"><pre>
|
91
|
+
static int[] EvenNumbers = new int[] { 2, 4, 6, 8 };
|
92
|
+
|
93
|
+
[Test, TestCaseSource("EvenNumbers")]
|
94
|
+
public void TestMethod(int num)
|
95
|
+
{
|
96
|
+
Assert.IsTrue( num % 2 == 0 );
|
97
|
+
}
|
98
|
+
</pre></div>
|
99
|
+
|
100
|
+
<p><b>Note:</b> Any user-defined struct intended to hold the arguments
|
101
|
+
will be passed directly to the test method, since a struct is a value type.
|
102
|
+
If you intend your user type to be used as described in the following item,
|
103
|
+
you must define it as a class.
|
104
|
+
|
105
|
+
<li><p>If it is any other type of object, it is examined using reflection
|
106
|
+
and any public fields or properties with the following names are used:
|
107
|
+
<p><dl>
|
108
|
+
<dt><b>Arguments</b>
|
109
|
+
<dd>An <b>object[]</b> representing the arguments to the method
|
110
|
+
<dt><b>Categories</b>
|
111
|
+
<dd>An IList of categories to be applied to the test case.
|
112
|
+
<dt><b>Description</b>
|
113
|
+
<dd>Sets the description property of the test
|
114
|
+
<dt><b>ExpectedException</b>
|
115
|
+
<dd>Specifies a the Type of an exception that should be thrown by this invocation
|
116
|
+
<dt><b>ExpectedExceptionName</b>
|
117
|
+
<dd>Specifies a the FullName of an exception that should be thrown by this invocation
|
118
|
+
<dt><b>Properties</b>
|
119
|
+
<dd>An IDictionary of properties to be applied to the test case.
|
120
|
+
Note that the values provided must be compatible with PropertiesAttribute.
|
121
|
+
In particular, use of custom types or enums will cause problems.
|
122
|
+
<dt><b>Result</b>
|
123
|
+
<dd>The expected result to be returned from the method, which must have
|
124
|
+
a compatible return type.
|
125
|
+
<dt><b>TestName</b>
|
126
|
+
<dd>Provides a name for the test. If not specified, a name is generated based on
|
127
|
+
the method name and the arguments provided
|
128
|
+
</dl>
|
129
|
+
<p>
|
130
|
+
<p>Although any object with the required fields or properties may be used,
|
131
|
+
NUnit provides the <b>TestCaseData</b> class for this purpose. The following
|
132
|
+
example returns <b>TestCaseData</b> instances from a data source in
|
133
|
+
a separately defined class.
|
134
|
+
|
135
|
+
<div class="code">
|
136
|
+
<pre>[TestFixture]
|
137
|
+
public class MyTests
|
138
|
+
{
|
139
|
+
[Test,TestCaseSource(typeof(MyFactoryClass),"TestCases")]
|
140
|
+
public void DivideTest(int n, int d, int q)
|
141
|
+
{
|
142
|
+
Assert.AreEqual( q, n / d );
|
143
|
+
}
|
144
|
+
|
145
|
+
...
|
146
|
+
}
|
147
|
+
|
148
|
+
public class MyFactoryClass
|
149
|
+
{
|
150
|
+
public static IEnumerable TestCases
|
151
|
+
{
|
152
|
+
get
|
153
|
+
{
|
154
|
+
yield return new TestCaseData( 12, 3 ).Returns( 4 );
|
155
|
+
yield return new TestCaseData( 12, 2 ).Returns( 6 );
|
156
|
+
yield return new TestCaseData( 12, 4 ).Returns( 3 );
|
157
|
+
yield return new TestCaseData( 0, 0 )
|
158
|
+
.Throws(typeof(DivideByZeroException))
|
159
|
+
.SetName("DivideByZero")
|
160
|
+
.SetDescription("An exception is expected");
|
161
|
+
}
|
162
|
+
}
|
163
|
+
}
|
164
|
+
</div>
|
165
|
+
|
166
|
+
<p>This example uses the fluent interface supported by <b>TestCaseData</b>
|
167
|
+
to make the program more readable. The last yield statement above is equivalent to
|
168
|
+
|
169
|
+
<div class="code"><pre>
|
170
|
+
TestCaseData data = new TestCaseData(0,0);
|
171
|
+
data.ExpectedException = typeof(DivideByZeroException;
|
172
|
+
data.TestName = "DivideByZero";
|
173
|
+
data.Description = "An exception is expected";
|
174
|
+
yield return data;
|
175
|
+
</pre>
|
176
|
+
</div>
|
177
|
+
|
178
|
+
<p><b>TestCaseData</b> supports the following properties
|
179
|
+
and methods, which may be appended to an instance in any order.
|
180
|
+
|
181
|
+
<p>
|
182
|
+
<dl>
|
183
|
+
<dt><b>.Returns</b>
|
184
|
+
<dd>The expected result to be returned from the method, which must have
|
185
|
+
a compatible return type.
|
186
|
+
<dt><b>.SetCategory(string)</b>
|
187
|
+
<dd>Applies a category to the test
|
188
|
+
<dt><b>.SetProperty(string, string)</b>
|
189
|
+
<dt><b>.SetProperty(string, int)</b>
|
190
|
+
<dt><b>.SetProperty(string, double)</b>
|
191
|
+
<dd>Applies a named property and value to the test
|
192
|
+
<dt><b>.SetDescription(string)</b>
|
193
|
+
<dd>Sets the description property of the test
|
194
|
+
<dt><b>.SetName(string)</b>
|
195
|
+
<dd>Provides a name for the test. If not specified, a name is generated based on
|
196
|
+
the method name and the arguments provided
|
197
|
+
<dt><b>.Throws(Type)</b>
|
198
|
+
<dt><b>.Throws(string)</b>
|
199
|
+
<dd>Specifies a the Type or FullName of an exception that should be thrown by this invocation
|
200
|
+
</dl>
|
201
|
+
|
202
|
+
<h4>Note</h4>
|
203
|
+
<p>NUnit locates the test cases at the time the tests are loaded, creates
|
204
|
+
instances of each class with non-static sources and builds a list of
|
205
|
+
tests to be executed. Each source object is only created once at this
|
206
|
+
time and is destroyed after all tests are loaded. In the case of test
|
207
|
+
cases specified within the same class as the tests, a different object
|
208
|
+
is created each time the test is run, so no communication is possible
|
209
|
+
using non-static members of the class.
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
</div>
|
214
|
+
|
215
|
+
<!-- Submenu -->
|
216
|
+
<div id="subnav">
|
217
|
+
<ul>
|
218
|
+
<li><a href="index.html">NUnit 2.5</a></li>
|
219
|
+
<ul>
|
220
|
+
<li><a href="getStarted.html">Getting Started</a></li>
|
221
|
+
<li><a href="assertions.html">Assertions</a></li>
|
222
|
+
<li><a href="constraintModel.html">Constraints</a></li>
|
223
|
+
<li><a href="attributes.html">Attributes</a></li>
|
224
|
+
<ul>
|
225
|
+
<li><a href="category.html">Category</a></li>
|
226
|
+
<li><a href="combinatorial.html">Combinatorial</a></li>
|
227
|
+
<li><a href="culture.html">Culture</a></li>
|
228
|
+
<li><a href="datapoint.html">Datapoint(s)</a></li>
|
229
|
+
<li><a href="description.html">Description</a></li>
|
230
|
+
<li><a href="exception.html">Exception</a></li>
|
231
|
+
<li><a href="explicit.html">Explicit</a></li>
|
232
|
+
<li><a href="ignore.html">Ignore</a></li>
|
233
|
+
<li><a href="maxtime.html">Maxtime</a></li>
|
234
|
+
<li><a href="pairwise.html">Pairwise</a></li>
|
235
|
+
<li><a href="platform.html">Platform</a></li>
|
236
|
+
<li><a href="property.html">Property</a></li>
|
237
|
+
<li><a href="random.html">Random</a></li>
|
238
|
+
<li><a href="range.html">Range</a></li>
|
239
|
+
<li><a href="repeat.html">Repeat</a></li>
|
240
|
+
<li><a href="requiredAddin.html">RequiredAddin</a></li>
|
241
|
+
<li><a href="requiresMTA.html">Requires MTA</a></li>
|
242
|
+
<li><a href="requiresSTA.html">Requires STA</a></li>
|
243
|
+
<li><a href="requiresThread.html">Requires Thread</a></li>
|
244
|
+
<li><a href="sequential.html">Sequential</a></li>
|
245
|
+
<li><a href="setCulture.html">SetCulture</a></li>
|
246
|
+
<li><a href="setup.html">Setup</a></li>
|
247
|
+
<li><a href="setupFixture.html">SetupFixture</a></li>
|
248
|
+
<li><a href="suite.html">Suite</a></li>
|
249
|
+
<li><a href="teardown.html">Teardown</a></li>
|
250
|
+
<li><a href="test.html">Test</a></li>
|
251
|
+
<li><a href="testCase.html">TestCase</a></li>
|
252
|
+
<li id="current"><a href="testCaseSource.html">TestCaseSource</a></li>
|
253
|
+
<li><a href="testFixture.html">TestFixture</a></li>
|
254
|
+
<li><a href="fixtureSetup.html">TestFixtureSetUp</a></li>
|
255
|
+
<li><a href="fixtureTeardown.html">TestFixtureTearDown</a></li>
|
256
|
+
<li><a href="theory.html">Theory</a></li>
|
257
|
+
<li><a href="timeout.html">Timeout</a></li>
|
258
|
+
<li><a href="values.html">Values</a></li>
|
259
|
+
<li><a href="valueSource.html">ValueSource</a></li>
|
260
|
+
</ul>
|
261
|
+
<li><a href="nunit-console.html">Console Runner</a></li>
|
262
|
+
<li><a href="nunit-gui.html">Gui Runner</a></li>
|
263
|
+
<li><a href="configFiles.html">Configuration Files</a></li>
|
264
|
+
<li><a href="pnunit.html">PNUnit</a></li>
|
265
|
+
<li><a href="multiAssembly.html">Multiple Assemblies</a></li>
|
266
|
+
<li><a href="vsSupport.html">Visual Studio Support</a></li>
|
267
|
+
<li><a href="extensibility.html">Extensibility</a></li>
|
268
|
+
<li><a href="releaseNotes.html">Release Notes</a></li>
|
269
|
+
<li><a href="samples.html">Samples</a></li>
|
270
|
+
<li><a href="license.html">License</a></li>
|
271
|
+
</ul>
|
272
|
+
</ul>
|
273
|
+
</div>
|
274
|
+
<!-- End of Submenu -->
|
275
|
+
|
276
|
+
|
277
|
+
<!-- Standard Footer for NUnit.org -->
|
278
|
+
<div id="footer">
|
279
|
+
Copyright © 2009 Charlie Poole. All Rights Reserved.
|
280
|
+
</div>
|
281
|
+
<!-- End of Footer -->
|
282
|
+
|
283
|
+
</body>
|
284
|
+
</html>
|