|
0
|
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: Advanced Test Options</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 |
|
|
|
18 |
<!--there is no custom header content for this example--> |
|
|
19 |
|
|
|
20 |
<link type="text/css" rel="stylesheet" href="../../build/cssfonts/fonts-min.css" /> |
|
|
21 |
<script type="text/javascript" src="../../build/yui/yui-min.js"></script> |
|
|
22 |
|
|
|
23 |
</head> |
|
|
24 |
<body id="yahoo-com" class=" yui-skin-sam"> |
|
|
25 |
<div id="custom-doc" class="yui-t2"> |
|
|
26 |
<div id="hd"> |
|
|
27 |
<div id="ygunav"> |
|
|
28 |
<p> |
|
|
29 |
<em> |
|
|
30 |
<a href="http://developer.yahoo.com/yui/3/">YUI 3.x Home</a> <i> - </i> |
|
|
31 |
</em> |
|
|
32 |
</p> |
|
|
33 |
<form action="http://search.yahoo.com/search" id="sitesearchform"> |
|
|
34 |
<input name="vs" type="hidden" value="developer.yahoo.com"> |
|
|
35 |
<input name="vs" type="hidden" value="yuiblog.com"> |
|
|
36 |
<div id="sitesearch"> |
|
|
37 |
<label for="searchinput">Site Search (YDN & YUIBlog): </label> |
|
|
38 |
<input type="text" id="searchinput" name="p"> |
|
|
39 |
<input type="submit" value="Search" id="searchsubmit" class="ygbt"> |
|
|
40 |
</div> |
|
|
41 |
</form> |
|
|
42 |
</div> |
|
|
43 |
<div id="ygma"><a href="../../"><img src="../../assets/logo.gif" border="0" width="200" height="93"></a></div> |
|
|
44 |
<div id="pagetitle"><h1>YUI Library Examples: Test: Advanced Test Options</h1></div> |
|
|
45 |
</div> |
|
|
46 |
<div id="bd"> |
|
|
47 |
|
|
|
48 |
<div id="bar-note"><p><strong>Note:</strong> This is YUI 3.x. Looking for <a href="http://developer.yahoo.com/yui/">YUI 2.x</a>?</p></div> |
|
|
49 |
|
|
|
50 |
<div id="yui-main"> |
|
|
51 |
<div class="yui-b"> |
|
|
52 |
<div class="yui-ge"> |
|
|
53 |
<div class="yui-u first example" id="main"> |
|
|
54 |
|
|
|
55 |
<h2>Test: Advanced Test Options</h2> |
|
|
56 |
|
|
|
57 |
<div id="example" class="promo"> |
|
|
58 |
<p> |
|
|
59 |
<p>This example shows how to use advanced test options, which allow you to specify additional information about how a test should be run. |
|
|
60 |
Each <a href="/yui/test/#testcase"><code>TestCase</code></a> can specify up to three different options for tests, |
|
|
61 |
including tests that should be ignored, tests that should throw an error, and tests that should fail.</p> </p> |
|
|
62 |
|
|
|
63 |
<div class="module example-container "> |
|
|
64 |
<div class="hd exampleHd"> |
|
|
65 |
<p class="newWindowButton yui-skin-sam"> |
|
|
66 |
<a href="test-advanced-test-options_clean.html" target="_blank">View example in new window.</a> |
|
|
67 |
</p> |
|
|
68 |
</div> <div id="example-canvas" class="bd"> |
|
|
69 |
|
|
|
70 |
|
|
|
71 |
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
72 |
|
|
|
73 |
<div id="testLogger"></div> |
|
|
74 |
<script type="text/javascript"> |
|
|
75 |
YUI({base:"../../build/", timeout: 10000}).use("node", "console", "test",function (Y) { |
|
|
76 |
|
|
|
77 |
Y.namespace("example.test"); |
|
|
78 |
|
|
|
79 |
Y.example.test.AdvancedOptionsTestCase = new Y.Test.Case({ |
|
|
80 |
|
|
|
81 |
//the name of the test case - if not provided, one is automatically generated |
|
|
82 |
name: "Advanced Options Tests", |
|
|
83 |
|
|
|
84 |
/* |
|
|
85 |
* Specifies tests that "should" be doing something other than the expected. |
|
|
86 |
*/ |
|
|
87 |
_should: { |
|
|
88 |
|
|
|
89 |
/* |
|
|
90 |
* Tests listed in here should fail, meaning that if they fail, the test |
|
|
91 |
* has passed. This is used mostly for YuiTest to test itself, but may |
|
|
92 |
* be helpful in other cases. |
|
|
93 |
*/ |
|
|
94 |
fail: { |
|
|
95 |
|
|
|
96 |
//the test named "testFail" should fail |
|
|
97 |
testFail: true |
|
|
98 |
|
|
|
99 |
}, |
|
|
100 |
|
|
|
101 |
/* |
|
|
102 |
* Tests listed here should throw an error of some sort. If they throw an |
|
|
103 |
* error, then they are considered to have passed. |
|
|
104 |
*/ |
|
|
105 |
error: { |
|
|
106 |
|
|
|
107 |
/* |
|
|
108 |
* You can specify "true" for each test, in which case any error will |
|
|
109 |
* cause the test to pass. |
|
|
110 |
*/ |
|
|
111 |
testGenericError: true, |
|
|
112 |
|
|
|
113 |
/* |
|
|
114 |
* You can specify an error message, in which case the test passes only |
|
|
115 |
* if the error thrown matches the given message. |
|
|
116 |
*/ |
|
|
117 |
testStringError: "I'm a specific error message.", |
|
|
118 |
testStringError2: "I'm a specific error message.", |
|
|
119 |
|
|
|
120 |
/* |
|
|
121 |
* You can also specify an error object, in which case the test passes only |
|
|
122 |
* if the error thrown is on the same type and has the same message. |
|
|
123 |
*/ |
|
|
124 |
testObjectError: new TypeError("Number expected."), |
|
|
125 |
testObjectError2: new TypeError("Number expected."), |
|
|
126 |
testObjectError3: new TypeError("Number expected.") |
|
|
127 |
|
|
|
128 |
}, |
|
|
129 |
|
|
|
130 |
/* |
|
|
131 |
* Tests listed here should be ignored when the test case is run. For these tests, |
|
|
132 |
* setUp() and tearDown() are not called. |
|
|
133 |
*/ |
|
|
134 |
ignore : { |
|
|
135 |
|
|
|
136 |
testIgnore: true |
|
|
137 |
|
|
|
138 |
} |
|
|
139 |
}, |
|
|
140 |
|
|
|
141 |
//------------------------------------------------------------------------- |
|
|
142 |
// Basic tests - all method names must begin with "test" |
|
|
143 |
//------------------------------------------------------------------------- |
|
|
144 |
|
|
|
145 |
testFail : function() { |
|
|
146 |
|
|
|
147 |
//force a failure - but since this test "should" fail, it will pass |
|
|
148 |
Y.Assert.fail("Something bad happened."); |
|
|
149 |
|
|
|
150 |
}, |
|
|
151 |
|
|
|
152 |
testGenericError : function() { |
|
|
153 |
throw new Error("Generic error"); |
|
|
154 |
}, |
|
|
155 |
|
|
|
156 |
testStringError : function() { |
|
|
157 |
|
|
|
158 |
//throw a specific error message - this will pass because it "should" happen |
|
|
159 |
throw new Error("I'm a specific error message."); |
|
|
160 |
}, |
|
|
161 |
|
|
|
162 |
testStringError2 : function() { |
|
|
163 |
|
|
|
164 |
//throw a specific error message - this will fail because the message isn't expected |
|
|
165 |
throw new Error("I'm a specific error message, but a wrong one."); |
|
|
166 |
}, |
|
|
167 |
|
|
|
168 |
testObjectError : function() { |
|
|
169 |
|
|
|
170 |
//throw a specific error and message - this will pass because it "should" happen |
|
|
171 |
throw new TypeError("Number expected."); |
|
|
172 |
}, |
|
|
173 |
|
|
|
174 |
testObjectError2 : function() { |
|
|
175 |
|
|
|
176 |
//throw a specific error and message - this will fail because the type doesn't match |
|
|
177 |
throw new Error("Number expected."); |
|
|
178 |
}, |
|
|
179 |
|
|
|
180 |
testObjectError3 : function() { |
|
|
181 |
|
|
|
182 |
//throw a specific error and message - this will fail because the message doesn't match |
|
|
183 |
throw new TypeError("String expected."); |
|
|
184 |
}, |
|
|
185 |
|
|
|
186 |
testIgnore : function () { |
|
|
187 |
alert("You'll never see this."); |
|
|
188 |
} |
|
|
189 |
|
|
|
190 |
}); |
|
|
191 |
|
|
|
192 |
|
|
|
193 |
//create the console |
|
|
194 |
var r = new Y.Console({ |
|
|
195 |
verbose : true, |
|
|
196 |
newestOnTop : false |
|
|
197 |
}); |
|
|
198 |
|
|
|
199 |
r.render('#testLogger'); |
|
|
200 |
|
|
|
201 |
Y.Test.Runner.add(Y.example.test.AdvancedOptionsTestCase); |
|
|
202 |
|
|
|
203 |
//run the tests |
|
|
204 |
Y.Test.Runner.run(); |
|
|
205 |
}); |
|
|
206 |
|
|
|
207 |
</script> |
|
|
208 |
<!--END SOURCE CODE FOR EXAMPLE =============================== --> |
|
|
209 |
|
|
|
210 |
|
|
|
211 |
</div> |
|
|
212 |
</div> |
|
|
213 |
</div> |
|
|
214 |
|
|
|
215 |
<h2 class="first">Advanced Test Options</h2> |
|
|
216 |
|
|
|
217 |
<p>This example begins by creating a namespace and a <code>Y.Test.Case</code> object:</p> |
|
|
218 |
<textarea name="code" class="JScript" cols="60" rows="1"> |
|
|
219 |
Y.namespace("example.test"); |
|
|
220 |
Y.example.test.AdvancedOptionsTestCase = new Y.TestCase({ |
|
|
221 |
name: "Advanced Options Tests" |
|
|
222 |
}); |
|
|
223 |
</textarea> |
|
|
224 |
|
|
|
225 |
<p>This <code>Y.Test.Case</code> serves as the basis for this example.</p> |
|
|
226 |
|
|
|
227 |
<h3>Using <code>_should</code></h3> |
|
|
228 |
|
|
|
229 |
<p>Immediately after the <code>name</code> of the <code>Y.Test.Case</code> is defined, there is a <code>_should</code> property. |
|
|
230 |
This property specifies information about how tests <em>should</em> behave and is defined as an object literal with one |
|
|
231 |
or more of the following properties: <code>fail</code>, <code>error</code>, and <code>ignore</code>.Each of these three |
|
|
232 |
is also defined as an object literal whose property names map directly to the names of test methods in the <code>Y.Test.Case</code>. |
|
|
233 |
This example uses all three properties:</p> |
|
|
234 |
<textarea name="code" class="JScript" cols="60" rows="1"> |
|
|
235 |
Y.example.test.AdvancedOptionsTestCase = new Y.TestCase({ |
|
|
236 |
|
|
|
237 |
//the name of the test case - if not provided, one is automatically generated |
|
|
238 |
name: "Advanced Options Tests", |
|
|
239 |
|
|
|
240 |
/* |
|
|
241 |
* Specifies tests that "should" be doing something other than the expected. |
|
|
242 |
*/ |
|
|
243 |
_should: { |
|
|
244 |
|
|
|
245 |
/* |
|
|
246 |
* Tests listed in here should fail, meaning that if they fail, the test |
|
|
247 |
* has passed. This is used mostly for YuiTest to test itself, but may |
|
|
248 |
* be helpful in other cases. |
|
|
249 |
*/ |
|
|
250 |
fail: { |
|
|
251 |
|
|
|
252 |
//the test named "testFail" should fail |
|
|
253 |
testFail: true |
|
|
254 |
|
|
|
255 |
}, |
|
|
256 |
|
|
|
257 |
/* |
|
|
258 |
* Tests listed here should throw an error of some sort. If they throw an |
|
|
259 |
* error, then they are considered to have passed. |
|
|
260 |
*/ |
|
|
261 |
error: { |
|
|
262 |
|
|
|
263 |
/* |
|
|
264 |
* You can specify "true" for each test, in which case any error will |
|
|
265 |
* cause the test to pass. |
|
|
266 |
*/ |
|
|
267 |
testGenericError: true, |
|
|
268 |
|
|
|
269 |
/* |
|
|
270 |
* You can specify an error message, in which case the test passes only |
|
|
271 |
* if the error thrown matches the given message. |
|
|
272 |
*/ |
|
|
273 |
testStringError: "I'm a specific error message.", |
|
|
274 |
testStringError2: "I'm a specific error message.", |
|
|
275 |
|
|
|
276 |
/* |
|
|
277 |
* You can also specify an error object, in which case the test passes only |
|
|
278 |
* if the error thrown is on the same type and has the same message. |
|
|
279 |
*/ |
|
|
280 |
testObjectError: new TypeError("Number expected."), |
|
|
281 |
testObjectError2: new TypeError("Number expected."), |
|
|
282 |
testObjectError3: new TypeError("Number expected.") |
|
|
283 |
|
|
|
284 |
}, |
|
|
285 |
|
|
|
286 |
/* |
|
|
287 |
* Tests listed here should be ignored when the test case is run. For these tests, |
|
|
288 |
* setUp() and tearDown() are not called. |
|
|
289 |
*/ |
|
|
290 |
ignore : { |
|
|
291 |
|
|
|
292 |
testIgnore: true |
|
|
293 |
|
|
|
294 |
} |
|
|
295 |
}, |
|
|
296 |
|
|
|
297 |
... |
|
|
298 |
}); |
|
|
299 |
</textarea> |
|
|
300 |
|
|
|
301 |
<p>This <code>Y.Test.Case</code> specifies one test that should fail, six that should throw an error, and one that should be ignored.</p> |
|
|
302 |
<p>In the <code>fail</code> section, the test method <code>testFail()</code> is specified as one that should fail. By adding the |
|
|
303 |
property <code>testFail</code> and settings its value to true, the <code>Y.Test.Runner</code> knows that this test is expected to fail. |
|
|
304 |
If the test were to be run without failing, it would be considered a failure of the test. This feature is useful when testing |
|
|
305 |
YUI Test itself or addon components to YUI Test.</p> |
|
|
306 |
<p>Moving on to the <code>error</code> section, there are six tests specified that should throw an error. There are three different ways |
|
|
307 |
to indicate that a test is expected to throw an error. The first is simply to add a property with the same name as the test method |
|
|
308 |
and set its value equal to true (similar to specifying tests that should fail). In this example, the <code>testGenericError()</code> |
|
|
309 |
method is specified this way. When specified like this, the test passes regardless of the type of error that occurs. This can be |
|
|
310 |
dangerous since unexpected errors will also cause the test to pass. To be more specific, set the property value for the test method |
|
|
311 |
to an error message string. When a string is used instead of the Boolean true, the test passes only when an error is thrown and that |
|
|
312 |
error message matches the string. In this example, <code>testStringError()</code> and <code>testStringError2()</code> expect an error |
|
|
313 |
to be thrown with an error message of "I'm a specific error message." If any other error occurs inside of the these methods, |
|
|
314 |
the test will fail because the error message doesn't match. The last way to specify an error should occur is to create an actual error |
|
|
315 |
object, which is the case with <code>testObjectError()</code>, <code>testObjectError2()</code>, and <code>testObjectError3()</code>. |
|
|
316 |
When specified in this way, a test will pass only when an error is thrown whose constructor and error message match that of the |
|
|
317 |
error object.</p> |
|
|
318 |
<p>The last section is <code>ignore</code>, which determines tests that should be ignored. In this example, the method <code>testIgnore()</code> |
|
|
319 |
is set to be ignored when the <code>Y.Test.Case</code> is executed. Test in the <code>ignore</code> section are specified the same way |
|
|
320 |
as those in the <code>fail</code> section, by adding the name as a property and setting its value to true.</p> |
|
|
321 |
|
|
|
322 |
<h3>Creating the test methods</h3> |
|
|
323 |
|
|
|
324 |
<p>The next part of the example contains the actual test methods. Since each test method is specified as having a certain behavior in |
|
|
325 |
<code>_should</code>, they each do something to show their particular functionality.</p> |
|
|
326 |
<p>The first method is <code>testFail()</code>, which does nothing but purposely fail. Since this method is specified as one that should |
|
|
327 |
fail, it means that this test will pass:</p> |
|
|
328 |
<textarea name="code" class="JScript" cols="60" rows="1"> |
|
|
329 |
Y.example.test.AdvancedOptionsTestCase = new Y.Test.Case({ |
|
|
330 |
|
|
|
331 |
//the name of the test case - if not provided, one is automatically generated |
|
|
332 |
name: "Advanced Options Tests", |
|
|
333 |
|
|
|
334 |
... |
|
|
335 |
|
|
|
336 |
testFail : function() { |
|
|
337 |
|
|
|
338 |
//force a failure - but since this test "should" fail, it will pass |
|
|
339 |
Y.Assert.fail("Something bad happened."); |
|
|
340 |
|
|
|
341 |
}, |
|
|
342 |
|
|
|
343 |
... |
|
|
344 |
}); |
|
|
345 |
</textarea> |
|
|
346 |
<p>This method uses <code>Assert.fail()</code> to force the test to fail. This type of method is helpful if you are creating your own |
|
|
347 |
type of assert methods that should fail when certain data is passed in.</p> |
|
|
348 |
<p>Next, the test methods that should error are defined. The <code>testGenericError()</code> method is specified as needing to throw |
|
|
349 |
an error to pass. In the <code>error</code> section, <code>testGenericError</code> is set to true, meaning that any error causes |
|
|
350 |
this method to pass. To illustrate this, the method simply throws an error:</p> |
|
|
351 |
<textarea name="code" class="JScript" cols="60" rows="1"> |
|
|
352 |
Y.example.test.AdvancedOptionsTestCase = new Y.Test.Case({ |
|
|
353 |
|
|
|
354 |
//the name of the test case - if not provided, one is automatically generated |
|
|
355 |
name: "Advanced Options Tests", |
|
|
356 |
|
|
|
357 |
... |
|
|
358 |
|
|
|
359 |
testGenericError : function() { |
|
|
360 |
throw new Error("Generic error"); |
|
|
361 |
}, |
|
|
362 |
|
|
|
363 |
... |
|
|
364 |
}); |
|
|
365 |
</textarea> |
|
|
366 |
<p>The fact that this method throws an error is enough to cause it to pass (the type of error and error message don't matter). The next |
|
|
367 |
two methods, <code>testStringError()</code> and <code>testStringError2()</code> are specified as throwing an error with a specific |
|
|
368 |
message ("I'm a specific error message."):</p> |
|
|
369 |
<textarea name="code" class="JScript" cols="60" rows="1"> |
|
|
370 |
Y.example.test.AdvancedOptionsTestCase = new Y.Test.Case({ |
|
|
371 |
|
|
|
372 |
//the name of the test case - if not provided, one is automatically generated |
|
|
373 |
name: "Advanced Options Tests", |
|
|
374 |
|
|
|
375 |
... |
|
|
376 |
|
|
|
377 |
testStringError : function() { |
|
|
378 |
|
|
|
379 |
//throw a specific error message - this will pass because it "should" happen |
|
|
380 |
throw new Error("I'm a specific error message."); |
|
|
381 |
}, |
|
|
382 |
|
|
|
383 |
testStringError2 : function() { |
|
|
384 |
|
|
|
385 |
//throw a specific error message - this will fail because the message isn't expected |
|
|
386 |
throw new Error("I'm a specific error message, but a wrong one."); |
|
|
387 |
}, |
|
|
388 |
|
|
|
389 |
... |
|
|
390 |
}); |
|
|
391 |
</textarea> |
|
|
392 |
<p>The <code>testStringError()</code> method will pass when executed because the error message matches up exactly with the one |
|
|
393 |
specified in the <code>error</code> section. The <code>testStringError2()</code> method, however, will fail because its |
|
|
394 |
error message is different from the one specified.</p> |
|
|
395 |
<p>To be more specific, <code>testObjectError()</code>, <code>testObjectError2()</code>, and <code>testObjectError3()</code>, |
|
|
396 |
specified an error type (<code>TypeError</code>) and an error messsage ("Number expected."):</p> |
|
|
397 |
<textarea name="code" class="JScript" cols="60" rows="1"> |
|
|
398 |
Y.example.test.AdvancedOptionsTestCase = new Y.Test.Case({ |
|
|
399 |
|
|
|
400 |
//the name of the test case - if not provided, one is automatically generated |
|
|
401 |
name: "Advanced Options Tests", |
|
|
402 |
|
|
|
403 |
... |
|
|
404 |
|
|
|
405 |
testObjectError : function() { |
|
|
406 |
|
|
|
407 |
//throw a specific error and message - this will pass because it "should" happen |
|
|
408 |
throw new TypeError("Number expected."); |
|
|
409 |
}, |
|
|
410 |
|
|
|
411 |
testObjectError2 : function() { |
|
|
412 |
|
|
|
413 |
//throw a specific error and message - this will fail because the type doesn't match |
|
|
414 |
throw new Error("Number expected."); |
|
|
415 |
}, |
|
|
416 |
|
|
|
417 |
testObjectError3 : function() { |
|
|
418 |
|
|
|
419 |
//throw a specific error and message - this will fail because the message doesn't match |
|
|
420 |
throw new TypeError("String expected."); |
|
|
421 |
}, |
|
|
422 |
|
|
|
423 |
... |
|
|
424 |
}); |
|
|
425 |
</textarea> |
|
|
426 |
<p>Of the these three methods, only <code>testObjectError()</code> will pass because it's the only one that throws a <code>TypeError</code> |
|
|
427 |
object with the message, "Number expected." The <code>testObjectError2()</code> method will fail because the type of error |
|
|
428 |
being thrown (<code>Error</code>) is different from the expected type (<code>TypeError</code>), as specified in the <code>error</code> |
|
|
429 |
section. The last method, <code>testObjectError3()</code>, also fails. Though it throws the right type of error, the error message |
|
|
430 |
doesn't match the one that was specified.</p> |
|
|
431 |
<p>The last method in the <code>Y.Test.Case</code> is <code>testIgnore()</code>, which is specified to be ignored. To be certain, this |
|
|
432 |
method pops up a message:</p> |
|
|
433 |
<textarea name="code" class="JScript" cols="60" rows="1"> |
|
|
434 |
Y.example.test.AdvancedOptionsTestCase = new Y.Test.Case({ |
|
|
435 |
|
|
|
436 |
//the name of the test case - if not provided, one is automatically generated |
|
|
437 |
name: "Advanced Options Tests", |
|
|
438 |
|
|
|
439 |
... |
|
|
440 |
|
|
|
441 |
testIgnore : function () { |
|
|
442 |
alert("You'll never see this."); |
|
|
443 |
} |
|
|
444 |
}); |
|
|
445 |
</textarea> |
|
|
446 |
<p>If this test weren't ignored, then the alert should be displayed. Since it is ignored, though, you will never see the alert. Additionally, |
|
|
447 |
there is a special message displayed in the <code>Y.Console</code> when a test is ignored.</p> |
|
|
448 |
|
|
|
449 |
<h3>Running the tests</h3> |
|
|
450 |
|
|
|
451 |
<p>With all of the tests defined, the last step is to run them:</p> |
|
|
452 |
|
|
|
453 |
<textarea name="code" class="JScript" cols="60" rows="1"> |
|
|
454 |
//create the console |
|
|
455 |
var r = new Y.Console({ |
|
|
456 |
verbose : true, |
|
|
457 |
newestOnTop : false |
|
|
458 |
}); |
|
|
459 |
|
|
|
460 |
r.render('#testLogger'); |
|
|
461 |
|
|
|
462 |
//add the test suite to the runner's queue |
|
|
463 |
Y.Test.Runner.add(Y.example.test.AdvancedOptionsTestCase); |
|
|
464 |
|
|
|
465 |
//run the tests |
|
|
466 |
Y.Test.Runner.run(); |
|
|
467 |
</textarea> |
|
|
468 |
|
|
|
469 |
<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 |
|
|
470 |
but you wouldn't see the results). After that, the <code>Y.Test.Runner</code> is loaded with the <code>Y.Test.Suite</code> object by calling |
|
|
471 |
<code>add()</code> (any number of <code>Y.Test.Case</code> and <code>Y.Test.Suite</code> objects can be added to a <code>Y.Test.Runner</code>, |
|
|
472 |
this example only adds one for simplicity). The very last step is to call <code>run()</code>, which begins executing the tests in its |
|
|
473 |
queue and displays the results in the <code>Y.Console</code>.</p> </div> |
|
|
474 |
<div class="yui-u sidebar"> |
|
|
475 |
|
|
|
476 |
|
|
|
477 |
<div id="examples" class="mod box4"> |
|
|
478 |
<div class="hd"> |
|
|
479 |
<h4> |
|
|
480 |
Test Examples:</h4> |
|
|
481 |
</div> |
|
|
482 |
<div class="bd"> |
|
|
483 |
<ul> |
|
|
484 |
<li><a href='../test/test-simple-example.html'>Simple Testing Example</a></li><li class='selected'><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><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> |
|
|
485 |
</div> |
|
|
486 |
</div> |
|
|
487 |
|
|
|
488 |
<div class="mod box4"> |
|
|
489 |
<div class="hd"> |
|
|
490 |
<h4>More Test Resources:</h4> |
|
|
491 |
</div> |
|
|
492 |
<div class="bd"> |
|
|
493 |
<ul> |
|
|
494 |
<!-- <li><a href="http://developer.yahoo.com/yui/test/">User's Guide</a> (external)</li> --> |
|
|
495 |
<li><a href="../../api/module_test.html">API Documentation</a></li> |
|
|
496 |
</ul> |
|
|
497 |
</div> |
|
|
498 |
</div> |
|
|
499 |
</div> |
|
|
500 |
</div> |
|
|
501 |
|
|
|
502 |
</div> |
|
|
503 |
</div> |
|
|
504 |
|
|
|
505 |
|
|
|
506 |
<div class="yui-b toc3" id="tocWrapper"> |
|
|
507 |
<!-- TABLE OF CONTENTS --> |
|
|
508 |
<div id="toc"> |
|
|
509 |
|
|
|
510 |
<ul> |
|
|
511 |
<li class="sect first">YUI 3.x Project</li><li class="item"><a title="The Yahoo! User Interface (YUI) Library, 3.x Branch, " href="http://developer.yahoo.com/yui/3/">YUI 3 Web Site (external)</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="The YUI Library can be downloaded from SourceForge" href="http://sourceforge.net/projects/yui/">YUI 3 on Sourceforge (external)</a></li><li class="item"><a title="YUI is free and open, offered under a BSD license." href="http://developer.yahoo.com/yui/3/license.html">YUI License (external)</a></li><li class="sect">YUI 3 Core - Examples</li><li class="item"><a title="YUI (Global Prerequisite) - Functional Examples" href="../../examples/yui/index.html">YUI (Global Prerequisite)</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</a></li><li class="item"><a title="Widget - Functional Examples" href="../../examples/widget/index.html">Widget</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="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</a></li><li class="item"><a title="DataSource - Functional Examples" href="../../examples/datasource/index.html">DataSource</a></li><li class="item"><a title="DataType - Functional Examples" href="../../examples/datatype/index.html">DataType</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="History - Functional Examples" href="../../examples/history/index.html">History</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="Queue - Functional Examples" href="../../examples/queue/index.html">Queue</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</a></li><li class="item"><a title="Slider - Functional Examples" href="../../examples/slider/index.html">Slider</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</a></li><li class="item"><a title="MenuNav Node Plugin - Functional Examples" href="../../examples/node-menunav/index.html">MenuNav Node Plugin</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</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">The YUI Community</li><li class="item"><a title="The Yahoo! User Interface Blog" href="http://yuiblog.com">YUI Blog (external)</a></li><li class="item"><a title="The Yahoo! Group YDN-JavaScript hosts the YUI community forum" href="http://tech.groups.yahoo.com/group/ydn-javascript/">YUI Forum (external)</a></li><li class="item"><a title="The Yahoo! Group yui3 is dedicated to the 3.x branch of the Yahoo! User Interface (YUI) Library." href="http://tech.groups.yahoo.com/group/yui3/">YUI 3 Forum (external)</a></li><li class="item"><a title="YUI is used by Yahoo! and by hundreds of other sites, including many you know and love." href="/yui/poweredby/">YUI Sightings (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><li class="sect">YUI Articles on the YUI Website</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="Reporting Bugs and Making Feature Requests for YUI Components" href="http://developer.yahoo.com/yui/articles/reportingbugs/">Bug Reports/Feature Requests (external)</a></li><li class="item"><a title="Serve YUI source files from Yahoo! -- free, fast, and simple" href="http://developer.yahoo.com/yui/3/articles/hosting/">Serving YUI Files from Yahoo! (external)</a></li></ul> |
|
|
512 |
</div> |
|
|
513 |
</div> |
|
|
514 |
</div><!--closes bd--> |
|
|
515 |
|
|
|
516 |
<div id="ft"> |
|
|
517 |
<p class="first">Copyright © 2009 Yahoo! Inc. All rights reserved.</p> |
|
|
518 |
<p><a href="http://privacy.yahoo.com/privacy/us/devel/index.html">Privacy Policy</a> - |
|
|
519 |
<a href="http://docs.yahoo.com/info/terms/">Terms of Service</a> - |
|
|
520 |
<a href="http://docs.yahoo.com/info/copyright/copyright.html">Copyright Policy</a> - |
|
|
521 |
<a href="http://careers.yahoo.com/">Job Openings</a></p> |
|
|
522 |
</div> |
|
|
523 |
</div> |
|
|
524 |
<script src="../../assets/dpSyntaxHighlighter.js"></script> |
|
|
525 |
<script language="javascript"> |
|
|
526 |
dp.SyntaxHighlighter.HighlightAll('code'); |
|
|
527 |
</script> |
|
|
528 |
</body> |
|
|
529 |
</html> |