Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="lib.html" title='Python Library Reference' /> | |
8 | <link rel='contents' href='contents.html' title="Contents" /> | |
9 | <link rel='index' href='genindex.html' title='Index' /> | |
10 | <link rel='last' href='about.html' title='About this document...' /> | |
11 | <link rel='help' href='about.html' title='About this document...' /> | |
12 | <link rel="next" href="testresult-objects.html" /> | |
13 | <link rel="prev" href="testcase-objects.html" /> | |
14 | <link rel="parent" href="module-unittest.html" /> | |
15 | <link rel="next" href="testresult-objects.html" /> | |
16 | <meta name='aesop' content='information' /> | |
17 | <title>5.3.6 TestSuite Objects </title> | |
18 | </head> | |
19 | <body> | |
20 | <DIV CLASS="navigation"> | |
21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
23 | <tr> | |
24 | <td class='online-navigation'><a rel="prev" title="5.3.5 TestCase Objects" | |
25 | href="testcase-objects.html"><img src='../icons/previous.png' | |
26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
27 | <td class='online-navigation'><a rel="parent" title="5.3 unittest " | |
28 | href="module-unittest.html"><img src='../icons/up.png' | |
29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
30 | <td class='online-navigation'><a rel="next" title="5.3.7 TestResult Objects" | |
31 | href="testresult-objects.html"><img src='../icons/next.png' | |
32 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
33 | <td align="center" width="100%">Python Library Reference</td> | |
34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
35 | href="contents.html"><img src='../icons/contents.png' | |
36 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
38 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
39 | <td class='online-navigation'><a rel="index" title="Index" | |
40 | href="genindex.html"><img src='../icons/index.png' | |
41 | border='0' height='32' alt='Index' width='32' /></A></td> | |
42 | </tr></table> | |
43 | <div class='online-navigation'> | |
44 | <b class="navlabel">Previous:</b> | |
45 | <a class="sectref" rel="prev" href="testcase-objects.html">5.3.5 TestCase Objects</A> | |
46 | <b class="navlabel">Up:</b> | |
47 | <a class="sectref" rel="parent" href="module-unittest.html">5.3 unittest </A> | |
48 | <b class="navlabel">Next:</b> | |
49 | <a class="sectref" rel="next" href="testresult-objects.html">5.3.7 TestResult Objects</A> | |
50 | </div> | |
51 | <hr /></div> | |
52 | </DIV> | |
53 | <!--End of Navigation Panel--> | |
54 | ||
55 | <H2><A NAME="SECTION007360000000000000000"></A><A NAME="testsuite-objects"></A> | |
56 | <BR> | |
57 | 5.3.6 TestSuite Objects | |
58 | ||
59 | </H2> | |
60 | ||
61 | <P> | |
62 | <tt class="class">TestSuite</tt> objects behave much like <tt class="class">TestCase</tt> objects, | |
63 | except they do not actually implement a test. Instead, they are used | |
64 | to aggregate tests into groups that should be run together. Some | |
65 | additional methods are available to add tests to <tt class="class">TestSuite</tt> | |
66 | instances: | |
67 | ||
68 | <P> | |
69 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
70 | <td><nobr><b><tt id='l2h-1158' xml:id='l2h-1158' class="method">addTest</tt></b>(</nobr></td> | |
71 | <td><var>test</var>)</td></tr></table></dt> | |
72 | <dd> | |
73 | Add a <tt class="class">TestCase</tt> or <tt class="class">TestSuite</tt> to the set of tests that | |
74 | make up the suite. | |
75 | </dl> | |
76 | ||
77 | <P> | |
78 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
79 | <td><nobr><b><tt id='l2h-1159' xml:id='l2h-1159' class="method">addTests</tt></b>(</nobr></td> | |
80 | <td><var>tests</var>)</td></tr></table></dt> | |
81 | <dd> | |
82 | Add all the tests from a sequence of <tt class="class">TestCase</tt> and | |
83 | <tt class="class">TestSuite</tt> instances to this test suite. | |
84 | </dl> | |
85 | ||
86 | <P> | |
87 | The <tt class="method">run()</tt> method is also slightly different: | |
88 | ||
89 | <P> | |
90 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> | |
91 | <td><nobr><b><tt id='l2h-1160' xml:id='l2h-1160' class="method">run</tt></b>(</nobr></td> | |
92 | <td><var>result</var>)</td></tr></table></dt> | |
93 | <dd> | |
94 | Run the tests associated with this suite, collecting the result into | |
95 | the test result object passed as <var>result</var>. Note that unlike | |
96 | <tt class="method">TestCase.run()</tt>, <tt class="method">TestSuite.run()</tt> requires the | |
97 | result object to be passed in. | |
98 | </dl> | |
99 | ||
100 | <P> | |
101 | In the typical usage of a <tt class="class">TestSuite</tt> object, the <tt class="method">run()</tt> | |
102 | method is invoked by a <tt class="class">TestRunner</tt> rather than by the end-user | |
103 | test harness. | |
104 | ||
105 | <P> | |
106 | ||
107 | <DIV CLASS="navigation"> | |
108 | <div class='online-navigation'> | |
109 | <p></p><hr /> | |
110 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
111 | <tr> | |
112 | <td class='online-navigation'><a rel="prev" title="5.3.5 TestCase Objects" | |
113 | href="testcase-objects.html"><img src='../icons/previous.png' | |
114 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
115 | <td class='online-navigation'><a rel="parent" title="5.3 unittest " | |
116 | href="module-unittest.html"><img src='../icons/up.png' | |
117 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
118 | <td class='online-navigation'><a rel="next" title="5.3.7 TestResult Objects" | |
119 | href="testresult-objects.html"><img src='../icons/next.png' | |
120 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
121 | <td align="center" width="100%">Python Library Reference</td> | |
122 | <td class='online-navigation'><a rel="contents" title="Table of Contents" | |
123 | href="contents.html"><img src='../icons/contents.png' | |
124 | border='0' height='32' alt='Contents' width='32' /></A></td> | |
125 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
126 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
127 | <td class='online-navigation'><a rel="index" title="Index" | |
128 | href="genindex.html"><img src='../icons/index.png' | |
129 | border='0' height='32' alt='Index' width='32' /></A></td> | |
130 | </tr></table> | |
131 | <div class='online-navigation'> | |
132 | <b class="navlabel">Previous:</b> | |
133 | <a class="sectref" rel="prev" href="testcase-objects.html">5.3.5 TestCase Objects</A> | |
134 | <b class="navlabel">Up:</b> | |
135 | <a class="sectref" rel="parent" href="module-unittest.html">5.3 unittest </A> | |
136 | <b class="navlabel">Next:</b> | |
137 | <a class="sectref" rel="next" href="testresult-objects.html">5.3.7 TestResult Objects</A> | |
138 | </div> | |
139 | </div> | |
140 | <hr /> | |
141 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
142 | </DIV> | |
143 | <!--End of Navigation Panel--> | |
144 | <ADDRESS> | |
145 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
146 | </ADDRESS> | |
147 | </BODY> | |
148 | </HTML> |