|
1 |
|
2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
|
3 <html> |
|
4 <head> |
|
5 <title>YUI Library Examples: Test: Asynchronous Testing</title> |
|
6 <meta http-equiv="content-type" content="text/html; charset=utf-8"> |
|
7 <link rel="stylesheet" type="text/css" href="../../assets/yui.css" > |
|
8 |
|
9 <style> |
|
10 /*Supplemental CSS for the YUI distribution*/ |
|
11 #custom-doc { width: 95%; min-width: 950px; } |
|
12 #pagetitle {background-image: url(../../assets/bg_hd.gif);} |
|
13 /* #pagetitle h1 {background-image: url(../../assets/title_h_bg.gif);}*/ |
|
14 </style> |
|
15 |
|
16 <link rel="stylesheet" type="text/css" href="../../assets/dpSyntaxHighlighter.css"> |
|
17 <link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" /> |
|
18 <script type="text/javascript" src="../../build/yui/yui-min.js"></script> |
|
19 <style type="text/css"> |
|
20 #testLogger { |
|
21 margin-bottom: 1em; |
|
22 } |
|
23 |
|
24 #testLogger .yui-console .yui-console-title { |
|
25 border: 0 none; |
|
26 color: #000; |
|
27 font-size: 13px; |
|
28 font-weight: bold; |
|
29 margin: 0; |
|
30 text-transform: none; |
|
31 } |
|
32 #testLogger .yui-console .yui-console-entry-meta { |
|
33 margin: 0; |
|
34 } |
|
35 |
|
36 .yui-skin-sam .yui-console-entry-pass .yui-console-entry-cat { |
|
37 background: #070; |
|
38 color: #fff; |
|
39 } |
|
40 </style> |
|
41 |
|
42 </head> |
|
43 <body id="yahoo-com" class=" yui-skin-sam"> |
|
44 <div id="custom-doc" class="yui-t2"> |
|
45 <div id="hd"> |
|
46 <div id="ygunav"> |
|
47 <p> |
|
48 <em> |
|
49 <a href="http://developer.yahoo.com/yui/3/">YUI 3.x Home</a> <i> - </i> |
|
50 </em> |
|
51 </p> |
|
52 <form action="http://search.yahoo.com/search" id="sitesearchform"> |
|
53 <input name="vs" type="hidden" value="developer.yahoo.com"> |
|
54 <input name="vs" type="hidden" value="yuiblog.com"> |
|
55 <div id="sitesearch"> |
|
56 <label for="searchinput">Site Search (YDN & YUIBlog): </label> |
|
57 <input type="text" id="searchinput" name="p"> |
|
58 <input type="submit" value="Search" id="searchsubmit" class="ygbt"> |
|
59 </div> |
|
60 </form> |
|
61 </div> |
|
62 <div id="ygma"><a href="../../"><img src="../../assets/logo.gif" border="0" width="200" height="93"></a></div> |
|
63 <div id="pagetitle"><h1>YUI Library Examples: Test: Asynchronous Testing</h1></div> |
|
64 </div> |
|
65 <div id="bd"> |
|
66 |
|
67 |
|
68 <div id="yui-main"> |
|
69 <div class="yui-b"> |
|
70 <div class="yui-ge"> |
|
71 <div class="yui-u first example" id="main"> |
|
72 |
|
73 <h2>Test: Asynchronous Testing</h2> |
|
74 |
|
75 <div id="example" class="promo"> |
|
76 <div class="example-intro"> |
|
77 <p>This example shows how to create an asynchronous test with the YUI Test framework for testing browser-based JavaScript code. |
|
78 A <code>Y.Test.Case</code> object is created with a test that waits for a |
|
79 few seconds before continuing. The <code>Y.Test.Runner</code> |
|
80 is then used to run the tests once the page has loaded.</p> </div> |
|
81 |
|
82 <div class="module example-container "> |
|
83 <div class="hd exampleHd"> |
|
84 <p class="newWindowButton yui-skin-sam"> |
|
85 <a href="test-async-test_clean.html" target="_blank">View example in new window.</a> |
|
86 </p> |
|
87 </div> <div id="example-canvas" class="bd"> |
|
88 |
|
89 |
|
90 <!--BEGIN SOURCE CODE FOR EXAMPLE =============================== --> |
|
91 |
|
92 <div id="testLogger"></div> |
|
93 <script type="text/javascript"> |
|
94 YUI({base:"../../build/", timeout: 10000}).use("node", "console", "test",function (Y) { |
|
95 |
|
96 Y.namespace("example.test"); |
|
97 |
|
98 Y.example.test.AsyncTestCase = new Y.Test.Case({ |
|
99 |
|
100 //name of the test case - if not provided, one is auto-generated |
|
101 name : "Asynchronous Tests", |
|
102 |
|
103 //--------------------------------------------------------------------- |
|
104 // setUp and tearDown methods - optional |
|
105 //--------------------------------------------------------------------- |
|
106 |
|
107 /* |
|
108 * Sets up data that is needed by each test. |
|
109 */ |
|
110 setUp : function () { |
|
111 this.data = { |
|
112 name: "test", |
|
113 year: 2007, |
|
114 beta: true |
|
115 }; |
|
116 }, |
|
117 |
|
118 /* |
|
119 * Cleans up everything that was created by setUp(). |
|
120 */ |
|
121 tearDown : function () { |
|
122 delete this.data; |
|
123 }, |
|
124 |
|
125 //--------------------------------------------------------------------- |
|
126 // Test methods - names must begin with "test" |
|
127 //--------------------------------------------------------------------- |
|
128 |
|
129 testWait : function (){ |
|
130 var Assert = Y.Assert; |
|
131 |
|
132 //do some assertions now |
|
133 Assert.isTrue(this.data.beta); |
|
134 Assert.isNumber(this.data.year); |
|
135 |
|
136 //wait five seconds and do some more |
|
137 this.wait(function(){ |
|
138 |
|
139 Assert.isString(this.data.name); |
|
140 |
|
141 }, 5000); |
|
142 |
|
143 } |
|
144 |
|
145 }); |
|
146 |
|
147 //create the console |
|
148 var r = new Y.Console({ |
|
149 newestOnTop : false, |
|
150 style: 'block' // to anchor in the example content |
|
151 }); |
|
152 |
|
153 r.render('#testLogger'); |
|
154 |
|
155 Y.Test.Runner.add(Y.example.test.AsyncTestCase); |
|
156 |
|
157 //run the tests |
|
158 Y.Test.Runner.run(); |
|
159 }); |
|
160 |
|
161 </script> |
|
162 |
|
163 <!--END SOURCE CODE FOR EXAMPLE =============================== --> |
|
164 |
|
165 |
|
166 </div> |
|
167 </div> |
|
168 </div> |
|
169 |
|
170 <h2 class="first">Asynchronous Test Example</h2> |
|
171 |
|
172 <p>This example begins by creating a namespace:</p> |
|
173 <div id="syntax1" class="yui-syntax-highlight"><div class="numbers"><pre class="javascript" style="font-family:monospace;"><ol><li class="li1"><div class="de1">Y.<span class="kw2">namespace</span><span class="br0">(</span><span class="st0">"example.test"</span><span class="br0">)</span><span class="sy0">;</span></div></li></ol></pre></div><div class="nonumbers"><pre class="javascript" style="font-family:monospace;">Y.<span class="kw2">namespace</span><span class="br0">(</span><span class="st0">"example.test"</span><span class="br0">)</span><span class="sy0">;</span></pre></div><textarea id="syntax1-plain">Y.namespace("example.test");</textarea></div><p>This namespace serves as the core object upon which others will be added (to prevent creating global objects).</p> |
|
174 |
|
175 <h3>Creating the TestCase</h3> |
|
176 |
|
177 <p>The first step is to create a new <code>Y.Test.Case</code> object called <code>AsyncTestCase</code>. |
|
178 To do so, using the <code>Y.Test.Case</code> constructor and pass in an object literal containing information about the tests to be run:</p> |
|
179 <div id="syntax2" class="yui-syntax-highlight"><div class="numbers"><pre class="javascript" style="font-family:monospace;"><ol><li class="li1"><div class="de1">Y.<span class="me1">example</span>.<span class="me1">test</span>.<span class="me1">AsyncTestCase</span> <span class="sy0">=</span> <span class="kw2">new</span> Y.<span class="me1">Test</span>.<span class="kw1">Case</span><span class="br0">(</span><span class="br0">{</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"> <span class="co1">//name of the test case - if not provided, one is auto-generated</span></div></li><li class="li1"><div class="de1"> <span class="kw3">name</span> <span class="sy0">:</span> <span class="st0">"Asynchronous Tests"</span><span class="sy0">,</span></div></li><li class="li2"><div class="de2"> </div></li><li class="li1"><div class="de1"> <span class="co1">//---------------------------------------------------------------------</span></div></li><li class="li1"><div class="de1"> <span class="co1">// setUp and tearDown methods - optional</span></div></li><li class="li1"><div class="de1"> <span class="co1">//---------------------------------------------------------------------</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li2"><div class="de2"> <span class="coMULTI">/*</span></div></li><li class="li1"><div class="de1"><span class="coMULTI"> * Sets up data that is needed by each test.</span></div></li><li class="li1"><div class="de1"><span class="coMULTI"> */</span></div></li><li class="li1"><div class="de1"> setUp <span class="sy0">:</span> <span class="kw2">function</span> <span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span></div></li><li class="li1"><div class="de1"> <span class="kw1">this</span>.<span class="me1">data</span> <span class="sy0">=</span> <span class="br0">{</span></div></li><li class="li2"><div class="de2"> <span class="kw3">name</span><span class="sy0">:</span> <span class="st0">"test"</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1"> year<span class="sy0">:</span> <span class="nu0">2007</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1"> beta<span class="sy0">:</span> <span class="kw2">true</span></div></li><li class="li1"><div class="de1"> <span class="br0">}</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> <span class="br0">}</span><span class="sy0">,</span></div></li><li class="li2"><div class="de2"> </div></li><li class="li1"><div class="de1"> <span class="coMULTI">/*</span></div></li><li class="li1"><div class="de1"><span class="coMULTI"> * Cleans up everything that was created by setUp().</span></div></li><li class="li1"><div class="de1"><span class="coMULTI"> */</span></div></li><li class="li1"><div class="de1"> tearDown <span class="sy0">:</span> <span class="kw2">function</span> <span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span></div></li><li class="li2"><div class="de2"> <span class="kw1">delete</span> <span class="kw1">this</span>.<span class="me1">data</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> <span class="br0">}</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"> <span class="co1">//---------------------------------------------------------------------</span></div></li><li class="li1"><div class="de1"> <span class="co1">// Test methods - names must begin with "test"</span></div></li><li class="li2"><div class="de2"> <span class="co1">//---------------------------------------------------------------------</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"> testWait <span class="sy0">:</span> <span class="kw2">function</span> <span class="br0">(</span><span class="br0">)</span><span class="br0">{</span></div></li><li class="li1"><div class="de1"> <span class="kw2">var</span> Assert <span class="sy0">=</span> Y.<span class="me1">Assert</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li2"><div class="de2"> <span class="co1">//do some assertions now</span></div></li><li class="li1"><div class="de1"> Assert.<span class="me1">isTrue</span><span class="br0">(</span><span class="kw1">this</span>.<span class="me1">data</span>.<span class="me1">beta</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> Assert.<span class="me1">isNumber</span><span class="br0">(</span><span class="kw1">this</span>.<span class="me1">data</span>.<span class="me1">year</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"> <span class="co1">//wait five seconds and do some more</span></div></li><li class="li2"><div class="de2"> <span class="kw1">this</span>.<span class="me1">wait</span><span class="br0">(</span><span class="kw2">function</span><span class="br0">(</span><span class="br0">)</span><span class="br0">{</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"> Assert.<span class="me1">isString</span><span class="br0">(</span><span class="kw1">this</span>.<span class="me1">data</span>.<span class="kw3">name</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"> <span class="br0">}</span><span class="sy0">,</span> <span class="nu0">5000</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li2"><div class="de2"> </div></li><li class="li1"><div class="de1"> <span class="br0">}</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"><span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span></div></li></ol></pre></div><div class="nonumbers"><pre class="javascript" style="font-family:monospace;">Y.<span class="me1">example</span>.<span class="me1">test</span>.<span class="me1">AsyncTestCase</span> <span class="sy0">=</span> <span class="kw2">new</span> Y.<span class="me1">Test</span>.<span class="kw1">Case</span><span class="br0">(</span><span class="br0">{</span> |
|
180 |
|
181 <span class="co1">//name of the test case - if not provided, one is auto-generated</span> |
|
182 <span class="kw3">name</span> <span class="sy0">:</span> <span class="st0">"Asynchronous Tests"</span><span class="sy0">,</span> |
|
183 |
|
184 <span class="co1">//---------------------------------------------------------------------</span> |
|
185 <span class="co1">// setUp and tearDown methods - optional</span> |
|
186 <span class="co1">//---------------------------------------------------------------------</span> |
|
187 |
|
188 <span class="coMULTI">/* |
|
189 * Sets up data that is needed by each test. |
|
190 */</span> |
|
191 setUp <span class="sy0">:</span> <span class="kw2">function</span> <span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span> |
|
192 <span class="kw1">this</span>.<span class="me1">data</span> <span class="sy0">=</span> <span class="br0">{</span> |
|
193 <span class="kw3">name</span><span class="sy0">:</span> <span class="st0">"test"</span><span class="sy0">,</span> |
|
194 year<span class="sy0">:</span> <span class="nu0">2007</span><span class="sy0">,</span> |
|
195 beta<span class="sy0">:</span> <span class="kw2">true</span> |
|
196 <span class="br0">}</span><span class="sy0">;</span> |
|
197 <span class="br0">}</span><span class="sy0">,</span> |
|
198 |
|
199 <span class="coMULTI">/* |
|
200 * Cleans up everything that was created by setUp(). |
|
201 */</span> |
|
202 tearDown <span class="sy0">:</span> <span class="kw2">function</span> <span class="br0">(</span><span class="br0">)</span> <span class="br0">{</span> |
|
203 <span class="kw1">delete</span> <span class="kw1">this</span>.<span class="me1">data</span><span class="sy0">;</span> |
|
204 <span class="br0">}</span><span class="sy0">,</span> |
|
205 |
|
206 <span class="co1">//---------------------------------------------------------------------</span> |
|
207 <span class="co1">// Test methods - names must begin with "test"</span> |
|
208 <span class="co1">//---------------------------------------------------------------------</span> |
|
209 |
|
210 testWait <span class="sy0">:</span> <span class="kw2">function</span> <span class="br0">(</span><span class="br0">)</span><span class="br0">{</span> |
|
211 <span class="kw2">var</span> Assert <span class="sy0">=</span> Y.<span class="me1">Assert</span><span class="sy0">;</span> |
|
212 |
|
213 <span class="co1">//do some assertions now</span> |
|
214 Assert.<span class="me1">isTrue</span><span class="br0">(</span><span class="kw1">this</span>.<span class="me1">data</span>.<span class="me1">beta</span><span class="br0">)</span><span class="sy0">;</span> |
|
215 Assert.<span class="me1">isNumber</span><span class="br0">(</span><span class="kw1">this</span>.<span class="me1">data</span>.<span class="me1">year</span><span class="br0">)</span><span class="sy0">;</span> |
|
216 |
|
217 <span class="co1">//wait five seconds and do some more</span> |
|
218 <span class="kw1">this</span>.<span class="me1">wait</span><span class="br0">(</span><span class="kw2">function</span><span class="br0">(</span><span class="br0">)</span><span class="br0">{</span> |
|
219 |
|
220 Assert.<span class="me1">isString</span><span class="br0">(</span><span class="kw1">this</span>.<span class="me1">data</span>.<span class="kw3">name</span><span class="br0">)</span><span class="sy0">;</span> |
|
221 |
|
222 <span class="br0">}</span><span class="sy0">,</span> <span class="nu0">5000</span><span class="br0">)</span><span class="sy0">;</span> |
|
223 |
|
224 <span class="br0">}</span> |
|
225 |
|
226 <span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span></pre></div><textarea id="syntax2-plain">Y.example.test.AsyncTestCase = new Y.Test.Case({ |
|
227 |
|
228 //name of the test case - if not provided, one is auto-generated |
|
229 name : "Asynchronous Tests", |
|
230 |
|
231 //--------------------------------------------------------------------- |
|
232 // setUp and tearDown methods - optional |
|
233 //--------------------------------------------------------------------- |
|
234 |
|
235 /* |
|
236 * Sets up data that is needed by each test. |
|
237 */ |
|
238 setUp : function () { |
|
239 this.data = { |
|
240 name: "test", |
|
241 year: 2007, |
|
242 beta: true |
|
243 }; |
|
244 }, |
|
245 |
|
246 /* |
|
247 * Cleans up everything that was created by setUp(). |
|
248 */ |
|
249 tearDown : function () { |
|
250 delete this.data; |
|
251 }, |
|
252 |
|
253 //--------------------------------------------------------------------- |
|
254 // Test methods - names must begin with "test" |
|
255 //--------------------------------------------------------------------- |
|
256 |
|
257 testWait : function (){ |
|
258 var Assert = Y.Assert; |
|
259 |
|
260 //do some assertions now |
|
261 Assert.isTrue(this.data.beta); |
|
262 Assert.isNumber(this.data.year); |
|
263 |
|
264 //wait five seconds and do some more |
|
265 this.wait(function(){ |
|
266 |
|
267 Assert.isString(this.data.name); |
|
268 |
|
269 }, 5000); |
|
270 |
|
271 } |
|
272 |
|
273 });</textarea></div><p>The object literal passed into the constructor contains two different sections. The first section contains the <code>name</code> property, |
|
274 which is used to determine which <code>Y.Test.Case</code> is being executed. A name is necessary, so one is generated if it isn't specified.</p> |
|
275 <p>Next, the <code>setUp()</code> and <code>tearDown()</code> methods are included. The <code>setUp()</code> method is used in a <code>Y.Test.Case</code> |
|
276 to set up data that may be needed for tests to be completed. This method is called immediately before each test is executed. For this example, |
|
277 <code>setUp()</code> creates a data object. The <code>tearDown()</code> is responsible for undoing what was done in <code>setUp()</code>. It is |
|
278 run immediately after each test is run and, in this case, deletes the data object that was created by <code>setUp</code>. These methods are optional.</p> |
|
279 <p>The second section contains the actual tests to be run. The only test is <code>testWait()</code>, which demonstrates using |
|
280 the <code>wait()</code> method to delay test execution. There are two arguments passed in: a function to run once the test resumes |
|
281 and the number of milliseconds to wait before running this function (same basic format as <code>setTimeout()</code>). When |
|
282 the test resumes, the function is executed in the context of the <code>Y.Test.Case</code> object, meaning that it still has |
|
283 access to all of the same data as the test that called <code>wait()</code>, including properties and methods on the <code>Y.Test.Case</code> |
|
284 itself. This example shows the anonymous function using both the <code>Y.Assert</code> object and the <code>data</code> property |
|
285 of the <code>Y.Test.Case</code>.</p> |
|
286 |
|
287 <h3>Running the tests</h3> |
|
288 |
|
289 <p>With all of the tests defined, the last step is to run them:</p> |
|
290 |
|
291 <div id="syntax3" class="yui-syntax-highlight"><div class="numbers"><pre class="javascript" style="font-family:monospace;"><ol><li class="li1"><div class="de1"><span class="co1">//create the console</span></div></li><li class="li1"><div class="de1"><span class="kw2">var</span> r <span class="sy0">=</span> <span class="kw2">new</span> Y.<span class="me1">Console</span><span class="br0">(</span><span class="br0">{</span></div></li><li class="li1"><div class="de1"> verbose <span class="sy0">:</span> <span class="kw2">true</span><span class="sy0">,</span></div></li><li class="li1"><div class="de1"> newestOnTop <span class="sy0">:</span> <span class="kw2">false</span></div></li><li class="li2"><div class="de2"><span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1">r.<span class="me1">render</span><span class="br0">(</span><span class="st0">'#testLogger'</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"><span class="co1">//add the test suite to the runner's queue</span></div></li><li class="li2"><div class="de2">Y.<span class="me1">Test</span>.<span class="me1">Runner</span>.<span class="me1">add</span><span class="br0">(</span>Y.<span class="me1">example</span>.<span class="me1">test</span>.<span class="me1">AsyncTestCase</span><span class="br0">)</span><span class="sy0">;</span></div></li><li class="li1"><div class="de1"> </div></li><li class="li1"><div class="de1"><span class="co1">//run the tests</span></div></li><li class="li1"><div class="de1">Y.<span class="me1">Test</span>.<span class="me1">Runner</span>.<span class="me1">run</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></div></li></ol></pre></div><div class="nonumbers"><pre class="javascript" style="font-family:monospace;"><span class="co1">//create the console</span> |
|
292 <span class="kw2">var</span> r <span class="sy0">=</span> <span class="kw2">new</span> Y.<span class="me1">Console</span><span class="br0">(</span><span class="br0">{</span> |
|
293 verbose <span class="sy0">:</span> <span class="kw2">true</span><span class="sy0">,</span> |
|
294 newestOnTop <span class="sy0">:</span> <span class="kw2">false</span> |
|
295 <span class="br0">}</span><span class="br0">)</span><span class="sy0">;</span> |
|
296 |
|
297 r.<span class="me1">render</span><span class="br0">(</span><span class="st0">'#testLogger'</span><span class="br0">)</span><span class="sy0">;</span> |
|
298 |
|
299 <span class="co1">//add the test suite to the runner's queue</span> |
|
300 Y.<span class="me1">Test</span>.<span class="me1">Runner</span>.<span class="me1">add</span><span class="br0">(</span>Y.<span class="me1">example</span>.<span class="me1">test</span>.<span class="me1">AsyncTestCase</span><span class="br0">)</span><span class="sy0">;</span> |
|
301 |
|
302 <span class="co1">//run the tests</span> |
|
303 Y.<span class="me1">Test</span>.<span class="me1">Runner</span>.<span class="me1">run</span><span class="br0">(</span><span class="br0">)</span><span class="sy0">;</span></pre></div><textarea id="syntax3-plain">//create the console |
|
304 var r = new Y.Console({ |
|
305 verbose : true, |
|
306 newestOnTop : false |
|
307 }); |
|
308 |
|
309 r.render('#testLogger'); |
|
310 |
|
311 //add the test suite to the runner's queue |
|
312 Y.Test.Runner.add(Y.example.test.AsyncTestCase); |
|
313 |
|
314 //run the tests |
|
315 Y.Test.Runner.run();</textarea></div> |
|
316 <p>Before running the tests, it's necessary to create a <code>Y.Console</code> object to display the results (otherwise the tests would run |
|
317 but you wouldn't see the results). After that, the <code>Y.Test.Runner</code> is loaded with the <code>Y.Test.Case</code> object by calling |
|
318 <code>add()</code> (any number of <code>Y.Test.Case</code> and <code>TestSuite</code> objects can be added to a <code>TestRunner</code>, |
|
319 this example only adds one for simplicity). The very last step is to call <code>run()</code>, which begins executing the tests in its |
|
320 queue and displays the results in the <code>Y.Console</code>.</p> </div> |
|
321 <div class="yui-u sidebar"> |
|
322 |
|
323 |
|
324 <div id="examples" class="mod box4"> |
|
325 <div class="hd"> |
|
326 <h4> |
|
327 Test Examples:</h4> |
|
328 </div> |
|
329 <div class="bd"> |
|
330 <ul> |
|
331 <li><a href='../test/test-simple-example.html'>Simple Testing Example</a></li><li><a href='../test/test-advanced-test-options.html'>Advanced Test Options</a></li><li><a href='../test/test-array-tests.html'>Array Processing</a></li><li class='selected'><a href='../test/test-async-test.html'>Asynchronous Testing</a></li><li><a href='../test/test-async-event-tests.html'>Asynchronous Event Testing</a></li> </ul> |
|
332 </div> |
|
333 </div> |
|
334 |
|
335 <div class="mod box4"> |
|
336 <div class="hd"> |
|
337 <h4>More Test Resources:</h4> |
|
338 </div> |
|
339 <div class="bd"> |
|
340 <ul> |
|
341 <!-- <li><a href="http://developer.yahoo.com/yui/test/">User's Guide</a> (external)</li> --> |
|
342 <li><a href="../../api/module_test.html">API Documentation</a></li></ul> |
|
343 </div> |
|
344 </div> |
|
345 </div> |
|
346 </div> |
|
347 |
|
348 </div> |
|
349 </div> |
|
350 |
|
351 |
|
352 <div class="yui-b toc3" id="tocWrapper"> |
|
353 <!-- TABLE OF CONTENTS --> |
|
354 <div id="toc"> |
|
355 |
|
356 <ul> |
|
357 <li class="sect first">YUI 3 Resources</li><li class="item"><a title="YUI 3 -- Yahoo! User Interface (YUI) Library" href="http://developer.yahoo.com/yui/3/">YUI 3 Web Site</a></li><li class="item"><a title="Examples of every YUI utility and control in action" href="../../examples/">YUI 3 Examples</a></li><li class="item"><a title="Instantly searchable API documentation for the entire YUI library." href="../../api/">YUI 3 API Docs</a></li><li class="item"><a title="YUI 3 Dependency Configurator -- configure your custom YUI implementation" href="http://developer.yahoo.com/yui/3/configurator">YUI 3 Dependency Configurator</a></li><li class="item"><a title="The YUI 3 Forum on YUILibrary.com" href="http://yuilibrary.com/forum/viewforum.php?f=15">YUI 3 Forums (external)</a></li><li class="item"><a title="Found a bug or a missing feature? Let us know on YUILibrary.com." href="http://developer.yahoo.com/yui/articles/reportingbugs/">Bug Reports/Feature Requests</a></li><li class="item"><a title="YUI is free and open, offered under a BSD license." href="http://developer.yahoo.com/yui/license.html">YUI License</a></li><li class="item"><a title="Download and fork the YUI project on GitHub" href="http://github.com/yui">YUI on Github</a></li><li class="item"><a title="The Yahoo! User Interface Blog" href="http://yuiblog.com">YUI Blog (external)</a></li><li class="sect">YUI 3 Core - Examples</li><li class="item"><a title="YUI Global Object - Functional Examples" href="../../examples/yui/index.html">YUI Global Object</a></li><li class="item"><a title="Event - Functional Examples" href="../../examples/event/index.html">Event</a></li><li class="item"><a title="Node - Functional Examples" href="../../examples/node/index.html">Node</a></li><li class="sect">YUI 3 Component Infrastructure - Examples</li><li class="item"><a title="Attribute - Functional Examples" href="../../examples/attribute/index.html">Attribute</a></li><li class="item"><a title="Plugin - Functional Examples" href="../../examples/plugin/index.html">Plugin <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Widget - Functional Examples" href="../../examples/widget/index.html">Widget <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="sect">YUI 3 Utilities - Examples</li><li class="item"><a title="Animation - Functional Examples" href="../../examples/anim/index.html">Animation</a></li><li class="item"><a title="AsyncQueue - Functional Examples" href="../../examples/async-queue/index.html">AsyncQueue</a></li><li class="item"><a title="Browser History - Functional Examples" href="../../examples/history/index.html">Browser History</a></li><li class="item"><a title="Cache - Functional Examples" href="../../examples/cache/index.html">Cache</a></li><li class="item"><a title="Cookie - Functional Examples" href="../../examples/cookie/index.html">Cookie</a></li><li class="item"><a title="DataSchema - Functional Examples" href="../../examples/dataschema/index.html">DataSchema <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="DataSource - Functional Examples" href="../../examples/datasource/index.html">DataSource <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="DataType - Functional Examples" href="../../examples/datatype/index.html">DataType <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Drag & Drop - Functional Examples" href="../../examples/dd/index.html">Drag & Drop</a></li><li class="item"><a title="Get - Functional Examples" href="../../examples/get/index.html">Get</a></li><li class="item"><a title="ImageLoader - Functional Examples" href="../../examples/imageloader/index.html">ImageLoader</a></li><li class="item"><a title="IO - Functional Examples" href="../../examples/io/index.html">IO</a></li><li class="item"><a title="JSON (JavaScript Object Notation) - Functional Examples" href="../../examples/json/index.html">JSON</a></li><li class="item"><a title="Stylesheet - Functional Examples" href="../../examples/stylesheet/index.html">Stylesheet</a></li><li class="sect">YUI 3 Widgets - Examples</li><li class="item"><a title="Overlay - Functional Examples" href="../../examples/overlay/index.html">Overlay <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Slider - Functional Examples" href="../../examples/slider/index.html">Slider <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="sect">YUI 3 Node Plugins - Examples</li><li class="item"><a title="FocusManager Node Plugin - Functional Examples" href="../../examples/node-focusmanager/index.html">FocusManager Node Plugin <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="MenuNav Node Plugin - Functional Examples" href="../../examples/node-menunav/index.html">MenuNav Node Plugin <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="sect">YUI 3 CSS - Examples</li><li class="item"><a title="YUI CSS Reset - Functional Examples" href="../../examples/cssreset/index.html">CSS Reset</a></li><li class="item"><a title="YUI Fonts - Functional Examples" href="../../examples/cssfonts/index.html">CSS Fonts</a></li><li class="item"><a title="YUI Base - Functional Examples" href="../../examples/cssbase/index.html">CSS Base</a></li><li class="sect">YUI 3 Developer Tools - Examples</li><li class="item"><a title="Console - Functional Examples" href="../../examples/console/index.html">Console <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Console Filters Plugin- Functional Examples" href="../../examples/console-filters/index.html">Plugin.ConsoleFilters <img src='http://l.yimg.com/a/i/not/beta_1.gif'></a></li><li class="item"><a title="Profiler - Functional Examples" href="../../examples/profiler/index.html">Profiler</a></li><li class="selected "><a title="Test - Functional Examples" href="../../examples/test/index.html">Test</a></li><li class="sect">Other Useful YUI 3 Resources</li><li class="item"><a title="Answers to Frequently Asked Questions about the YUI Library" href="http://developer.yahoo.com/yui/articles/faq/">YUI FAQ (external)</a></li><li class="item"><a title="Yahoo!'s philosophy of Graded Browser Support" href="http://developer.yahoo.com/yui/articles/gbs/">Graded Browser Support (external)</a></li><li class="item"><a title="Videos and podcasts from the YUI Team and from the Yahoo! frontend engineering community." href="http://developer.yahoo.com/yui/theater/">YUI Theater (external)</a></li></ul> |
|
358 </div> |
|
359 </div> |
|
360 </div><!--closes bd--> |
|
361 |
|
362 <div id="ft"> |
|
363 <p class="first">Copyright © 2009 Yahoo! Inc. All rights reserved.</p> |
|
364 <p><a href="http://privacy.yahoo.com/privacy/us/devel/index.html">Privacy Policy</a> - |
|
365 <a href="http://docs.yahoo.com/info/terms/">Terms of Service</a> - |
|
366 <a href="http://docs.yahoo.com/info/copyright/copyright.html">Copyright Policy</a> - |
|
367 <a href="http://careers.yahoo.com/">Job Openings</a></p> |
|
368 </div> |
|
369 </div> |
|
370 <script language="javascript"> |
|
371 var yuiConfig = {base:"../../build/", timeout: 10000}; |
|
372 </script> |
|
373 <script src="../../assets/syntax.js"></script> |
|
374 <script src="../../assets/dpSyntaxHighlighter.js"></script> |
|
375 <script language="javascript"> |
|
376 dp.SyntaxHighlighter.HighlightAll('code'); |
|
377 </script> |
|
378 </body> |
|
379 </html> |