~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/docs/test/test-simple-example.html

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html>
2
 
<html lang="en">
3
 
<head>
4
 
    <meta charset="utf-8">
5
 
    <title>Example: Simple Testing Example</title>
6
 
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
7
 
    <link rel="stylesheet" href="../assets/css/main.css">
8
 
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
9
 
    <script src="../../build/yui/yui-min.js"></script>
10
 
</head>
11
 
<body>
12
 
 
13
 
<div id="doc">
14
 
    <h1>Example: Simple Testing Example</h1>
15
 
 
16
 
    
17
 
        <a href="#toc" class="jump">Jump to Table of Contents</a>
18
 
    
19
 
 
20
 
    <div class="yui3-g">
21
 
        <div id="main" class="yui3-u">
22
 
            <div class="content"><div class="intro">
23
 
    <p>This example shows basic usage of the YUI Test framework for testing browser-based JavaScript code.
24
 
      Two different <a href="index.html#testcase"><code>TestCase</code></a> objects are created and added to a
25
 
      <a href="index.html#testsuite"><code>TestSuite</code></a> object. The <a href="index.html#testrunner"><code>TestRunner</code></a>
26
 
      is then used to run the tests once the page has loaded.</p>
27
 
</div>
28
 
 
29
 
<div class="example yui3-skin-sam">
30
 
    <style scoped>
31
 
    #testLogger {
32
 
        margin-bottom: 1em;
33
 
    }
34
 
 
35
 
    #testLogger .yui3-console .yui3-console-title {
36
 
        border: 0 none;
37
 
        color: #000;
38
 
        font-size: 13px;
39
 
        font-weight: bold;
40
 
        margin: 0;
41
 
        text-transform: none;
42
 
    }
43
 
    #testLogger .yui3-console .yui3-console-entry-meta {
44
 
        margin: 0;
45
 
    }
46
 
 
47
 
    .yui3-skin-sam .yui3-console-entry-pass .yui3-console-entry-cat {
48
 
        background: #070;
49
 
        color: #fff;
50
 
    }
51
 
    </style>
52
 
 
53
 
    <div id="testLogger"></div>
54
 
 
55
 
<script>
56
 
YUI().use('node', 'console', 'test', function (Y) {
57
 
 
58
 
    Y.namespace("example.test");
59
 
 
60
 
    Y.example.test.DataTestCase = new Y.Test.Case({
61
 
 
62
 
        //name of the test case - if not provided, one is auto-generated
63
 
        name : "Data Tests",
64
 
 
65
 
        //---------------------------------------------------------------------
66
 
        // setUp and tearDown methods - optional
67
 
        //---------------------------------------------------------------------
68
 
 
69
 
        /*
70
 
         * Sets up data that is needed by each test.
71
 
         */
72
 
        setUp : function () {
73
 
            this.data = {
74
 
                name: "test",
75
 
                year: 2007,
76
 
                beta: true
77
 
            };
78
 
        },
79
 
 
80
 
        /*
81
 
         * Cleans up everything that was created by setUp().
82
 
         */
83
 
        tearDown : function () {
84
 
            delete this.data;
85
 
        },
86
 
 
87
 
        //---------------------------------------------------------------------
88
 
        // Test methods - names must begin with "test"
89
 
        //---------------------------------------------------------------------
90
 
 
91
 
        testName : function () {
92
 
            var Assert = Y.Assert;
93
 
 
94
 
            Assert.isObject(this.data);
95
 
            Assert.isString(this.data.name);
96
 
            Assert.areEqual("test", this.data.name);
97
 
        },
98
 
 
99
 
        testYear : function () {
100
 
            var Assert = Y.Assert;
101
 
 
102
 
            Assert.isObject(this.data);
103
 
            Assert.isNumber(this.data.year);
104
 
            Assert.areEqual(2007, this.data.year);
105
 
        },
106
 
 
107
 
        testBeta : function () {
108
 
            var Assert = Y.Assert;
109
 
 
110
 
            Assert.isObject(this.data);
111
 
            Assert.isBoolean(this.data.beta);
112
 
            Assert.isTrue(this.data.beta);
113
 
        }
114
 
 
115
 
    });
116
 
 
117
 
    Y.example.test.ArrayTestCase = new Y.Test.Case({
118
 
 
119
 
        //name of the test case - if not provided, one is auto-generated
120
 
        name : "Array Tests",
121
 
 
122
 
        //---------------------------------------------------------------------
123
 
        // setUp and tearDown methods - optional
124
 
        //---------------------------------------------------------------------
125
 
 
126
 
        /*
127
 
         * Sets up data that is needed by each test.
128
 
         */
129
 
        setUp : function () {
130
 
            this.data = [0,1,2,3,4]
131
 
        },
132
 
 
133
 
        /*
134
 
         * Cleans up everything that was created by setUp().
135
 
         */
136
 
        tearDown : function () {
137
 
            delete this.data;
138
 
        },
139
 
 
140
 
        //---------------------------------------------------------------------
141
 
        // Test methods - names must begin with "test"
142
 
        //---------------------------------------------------------------------
143
 
 
144
 
        testPop : function () {
145
 
            var Assert = Y.Assert;
146
 
 
147
 
            var value = this.data.pop();
148
 
 
149
 
            Assert.areEqual(4, this.data.length);
150
 
            Assert.areEqual(4, value);
151
 
        },
152
 
 
153
 
        testPush : function () {
154
 
            var Assert = Y.Assert;
155
 
 
156
 
            this.data.push(5);
157
 
 
158
 
            Assert.areEqual(6, this.data.length);
159
 
            Assert.areEqual(5, this.data[5]);
160
 
        },
161
 
 
162
 
        testSplice : function () {
163
 
            var Assert = Y.Assert;
164
 
 
165
 
            this.data.splice(2, 1, 6, 7);
166
 
 
167
 
            Assert.areEqual(6, this.data.length);
168
 
            Assert.areEqual(6, this.data[2]);
169
 
            Assert.areEqual(7, this.data[3]);
170
 
        }
171
 
 
172
 
    });
173
 
 
174
 
    Y.example.test.ExampleSuite = new Y.Test.Suite("Example Suite");
175
 
    Y.example.test.ExampleSuite.add(Y.example.test.DataTestCase);
176
 
    Y.example.test.ExampleSuite.add(Y.example.test.ArrayTestCase);
177
 
 
178
 
    //create the console
179
 
    var r = new Y.Console({
180
 
        newestOnTop : false,
181
 
        style: 'block' // to anchor in the example content
182
 
    });
183
 
 
184
 
    r.render('#testLogger');
185
 
 
186
 
    Y.Test.Runner.add(Y.example.test.ExampleSuite);
187
 
 
188
 
    //run the tests
189
 
    Y.Test.Runner.run();
190
 
 
191
 
});
192
 
</script>
193
 
 
194
 
</div>
195
 
 
196
 
<h2 class="first" id="simple-test-example">Simple Test Example</h2>
197
 
 
198
 
<p>This example begins by creating a namespace:</p>
199
 
<pre class="code prettyprint">Y.namespace(&quot;example.test&quot;);</pre>
200
 
 
201
 
<p>This namespace serves as the core object upon which others will be added (to prevent creating global objects).</p>
202
 
 
203
 
<h3 id="creating-the-first-testcase">Creating the first TestCase</h3>
204
 
 
205
 
<p>The first step is to create a new <code>Y.Test.Case</code> object called <code>DataTestCase</code>.
206
 
  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>
207
 
<pre class="code prettyprint">Y.example.test.DataTestCase = new Y.Test.Case({
208
 
 
209
 
    &#x2F;&#x2F;name of the test case - if not provided, one is auto-generated
210
 
    name : &quot;Data Tests&quot;,
211
 
 
212
 
    &#x2F;&#x2F;---------------------------------------------------------------------
213
 
    &#x2F;&#x2F; setUp and tearDown methods - optional
214
 
    &#x2F;&#x2F;---------------------------------------------------------------------
215
 
 
216
 
    &#x2F;*
217
 
     * Sets up data that is needed by each test.
218
 
     *&#x2F;
219
 
    setUp : function () {
220
 
        this.data = {
221
 
            name: &quot;test&quot;,
222
 
            year: 2007,
223
 
            beta: true
224
 
        };
225
 
    },
226
 
 
227
 
    &#x2F;*
228
 
     * Cleans up everything that was created by setUp().
229
 
     *&#x2F;
230
 
    tearDown : function () {
231
 
        delete this.data;
232
 
    },
233
 
 
234
 
    &#x2F;&#x2F;---------------------------------------------------------------------
235
 
    &#x2F;&#x2F; Test methods - names must begin with &quot;test&quot;
236
 
    &#x2F;&#x2F;---------------------------------------------------------------------
237
 
 
238
 
    testName : function () {
239
 
        var Assert = Y.Assert;
240
 
 
241
 
        Assert.isObject(this.data);
242
 
        Assert.isString(this.data.name);
243
 
        Assert.areEqual(&quot;test&quot;, this.data.name);
244
 
    },
245
 
 
246
 
    testYear : function () {
247
 
        var Assert = Y.Assert;
248
 
 
249
 
        Assert.isObject(this.data);
250
 
        Assert.isNumber(this.data.year);
251
 
        Assert.areEqual(2007, this.data.year);
252
 
    },
253
 
 
254
 
    testBeta : function () {
255
 
        var Assert = Y.Assert;
256
 
 
257
 
        Assert.isObject(this.data);
258
 
        Assert.isBoolean(this.data.beta);
259
 
        Assert.isTrue(this.data.beta);
260
 
    }
261
 
 
262
 
});</pre>
263
 
 
264
 
<p>The object literal passed into the constructor contains a number of different sections. The first section contains the <code>name</code> property,
265
 
  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>
266
 
<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>
267
 
  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,
268
 
  <code>setUp()</code> creates a data object. The <code>tearDown()</code> is responsible for undoing what was done in <code>setUp()</code>. It is
269
 
  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>
270
 
<p>The last section contains the actual tests to be run. Test method names must always begin with the word &quot;test&quot; (all lowercase) in order
271
 
  to differentiate them from other methods that may be added to the object.</p>
272
 
<p>The first test in this object is <code>testName()</code>, which runs
273
 
  various assertions on <code>data.name</code>. Inside of this method, a shortcut to <code>Y.Assert</code> is set up and used to run three
274
 
  assertions: <code>isObject()</code> on <code>data</code>, <code>isString()</code> on <code>data.name</code> and <code>areEqual()</code> to compare
275
 
  <code>data.name</code> to the expected value, &quot;test&quot;. These assertions are arranged in order from least-specific to most-specific,
276
 
  which is the recommended way to arrange your assertions. Basically, the third assertion is useless to run unless the second has passes and the second
277
 
  can't possibly pass unless the first passed. Both <code>isObject()</code> and <code>isString()</code> accept a single argument, which is the value
278
 
  to test (you could optionally include a failure message as a second argument, though this is not required). The <code>areEqual()</code> method
279
 
  expects two arguments, the first being the expected value (&quot;test&quot;) and the second being the actual value (<code>data.name</code>).</p>
280
 
<p>The second and third tests follow the same pattern as the first with the exception that they work with different data types. The <code>testYear()</code>
281
 
  method works with <code>data.year</code>, which is a number and so runs tests specifically for numbers (<code>areEqual()</code> can be used with
282
 
  all data types). The <code>testBeta()</code> method works with <code>data.beta</code>, which is a Boolean, and so it uses the <code>isTrue()</code>
283
 
  assertion instead of <code>areEqual()</code> (though it could also use <code>areEqual(true, this.data.beta)</code>).</p>
284
 
 
285
 
 <h3 id="creating-the-second-testcase">Creating the second TestCase</h3>
286
 
 
287
 
 <p>Although it's possible that you'll have only one <code>Y.Test.Case</code> object, typically there is more than one, and so this example includes
288
 
   a second <code>Y.Test.Case</code>. This one tests some of the built-in functions of the <code>Array</code> object:</p>
289
 
<pre class="code prettyprint">Y.example.test.ArrayTestCase = new Y.Test.Case({
290
 
 
291
 
    &#x2F;&#x2F;name of the test case - if not provided, one is auto-generated
292
 
    name : &quot;Array Tests&quot;,
293
 
 
294
 
    &#x2F;&#x2F;---------------------------------------------------------------------
295
 
    &#x2F;&#x2F; setUp and tearDown methods - optional
296
 
    &#x2F;&#x2F;---------------------------------------------------------------------
297
 
 
298
 
    &#x2F;*
299
 
     * Sets up data that is needed by each test.
300
 
     *&#x2F;
301
 
    setUp : function () {
302
 
        this.data = [0,1,2,3,4]
303
 
    },
304
 
 
305
 
    &#x2F;*
306
 
     * Cleans up everything that was created by setUp().
307
 
     *&#x2F;
308
 
    tearDown : function () {
309
 
        delete this.data;
310
 
    },
311
 
 
312
 
    &#x2F;&#x2F;---------------------------------------------------------------------
313
 
    &#x2F;&#x2F; Test methods - names must begin with &quot;test&quot;
314
 
    &#x2F;&#x2F;---------------------------------------------------------------------
315
 
 
316
 
    testPop : function () {
317
 
        var Assert = Y.Assert;
318
 
 
319
 
        var value = this.data.pop();
320
 
 
321
 
        Assert.areEqual(4, this.data.length);
322
 
        Assert.areEqual(4, value);
323
 
    },
324
 
 
325
 
    testPush : function () {
326
 
        var Assert = Y.Assert;
327
 
 
328
 
        this.data.push(5);
329
 
 
330
 
        Assert.areEqual(6, this.data.length);
331
 
        Assert.areEqual(5, this.data[5]);
332
 
    },
333
 
 
334
 
    testSplice : function () {
335
 
        var Assert = Y.Assert;
336
 
 
337
 
        this.data.splice(2, 1, 6, 7);
338
 
 
339
 
        Assert.areEqual(6, this.data.length);
340
 
        Assert.areEqual(6, this.data[2]);
341
 
        Assert.areEqual(7, this.data[3]);
342
 
    }
343
 
 
344
 
});</pre>
345
 
 
346
 
 <p>As with the first <code>Y.Test.Case</code>, this one is split up into three sections: the name, the <code>setUp()</code> and <code>tearDown()</code>
347
 
  methods, and the test methods. The <code>setUp()</code> method in this <code>Y.Test.Case</code> creates an array of data to be used by the various
348
 
  tests while the <code>tearDown()</code> method destroys the array. The test methods are very simple, testing the <code>pop()</code>, <code>push()</code>,
349
 
  and <code>splice()</code> methods. Each test method uses <code>areEqual()</code> exclusively, to show the different ways that it can be used.
350
 
  The <code>testPop()</code> method calls <code>pop()</code> on the array of values, then verifies that the length of the array has changed and
351
 
  that the value popped off is 4; the <code>testPush()</code> pushes a new value (5) onto the array and then verifies that the length of the array has
352
 
  changed and that the value is included in the correct location; the <code>testSplice()</code> method tests  <code>splice()</code> by removing one
353
 
  value that's already in the array and inserting two in its place.</p>
354
 
 
355
 
<h3 id="creating-the-testsuite">Creating the TestSuite</h3>
356
 
<p>To better organize the two <code>Y.Test.Case</code> objects, a <code>Y.Test.Suite</code> is created and those two <code>Y.Test.Case</code> objects are
357
 
  added to it:</p>
358
 
<pre class="code prettyprint">Y.example.test.ExampleSuite = new Y.Test.Suite(&quot;Example Suite&quot;);
359
 
Y.example.test.ExampleSuite.add(Y.example.test.DataTestCase);
360
 
Y.example.test.ExampleSuite.add(Y.example.test.ArrayTestCase);</pre>
361
 
 
362
 
<p>The first line creates a new <code>Y.Test.Suite</code> object using its constructor, which accepts a single argument - the name of the suite. As with
363
 
  the name of a <code>Y.Test.Case</code>, the <code>Y.Test.Suite</code> name is used to determine where execution is when tests are being executed. Although
364
 
  not required (one is generated if it's not provided), it is recommended that you select a meaningful name to aid in debugging.</p>
365
 
<p>Any number of <code>Y.Test.Case</code> and <code>Y.Test.Suite</code> objects can be added to a <code>Y.Test.Suite</code> by using the <code>add()</code>
366
 
  method. In this example, the two <code>Y.Test.Case</code> objects created earlier are added to the <code>Y.Test.Suite</code>.</p>
367
 
 
368
 
<h3 id="running-the-tests">Running the tests</h3>
369
 
 
370
 
<p>With all of the tests defined, the last step is to run them. This initialization is assigned to take place when all of the YUI
371
 
  components have been loaded:</p>
372
 
 
373
 
<pre class="code prettyprint">&#x2F;&#x2F;create the console
374
 
var r = new Y.Console({
375
 
    verbose : true,
376
 
    newestOnTop : false
377
 
});
378
 
 
379
 
r.render(&#x27;#testLogger&#x27;);
380
 
 
381
 
Y.Test.Runner.add(Y.example.test.ExampleSuite);
382
 
 
383
 
&#x2F;&#x2F;run the tests
384
 
Y.Test.Runner.run();</pre>
385
 
 
386
 
 
387
 
<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
388
 
  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
389
 
  <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>,
390
 
  this example only adds one for simplicity). The very last step is to call <code>run()</code>, which begins executing the tests in its
391
 
  queue and displays the results in the <code>Y.Console</code>.</p>
392
 
 
393
 
<h2 id="complete-example-source">Complete Example Source</h2>
394
 
 
395
 
<pre class="code prettyprint">&lt;div id=&quot;testLogger&quot;&gt;&lt;&#x2F;div&gt;
396
 
 
397
 
&lt;script&gt;
398
 
YUI().use(&#x27;node&#x27;, &#x27;console&#x27;, &#x27;test&#x27;, function (Y) {
399
 
 
400
 
    Y.namespace(&quot;example.test&quot;);
401
 
 
402
 
    Y.example.test.DataTestCase = new Y.Test.Case({
403
 
 
404
 
        &#x2F;&#x2F;name of the test case - if not provided, one is auto-generated
405
 
        name : &quot;Data Tests&quot;,
406
 
 
407
 
        &#x2F;&#x2F;---------------------------------------------------------------------
408
 
        &#x2F;&#x2F; setUp and tearDown methods - optional
409
 
        &#x2F;&#x2F;---------------------------------------------------------------------
410
 
 
411
 
        &#x2F;*
412
 
         * Sets up data that is needed by each test.
413
 
         *&#x2F;
414
 
        setUp : function () {
415
 
            this.data = {
416
 
                name: &quot;test&quot;,
417
 
                year: 2007,
418
 
                beta: true
419
 
            };
420
 
        },
421
 
 
422
 
        &#x2F;*
423
 
         * Cleans up everything that was created by setUp().
424
 
         *&#x2F;
425
 
        tearDown : function () {
426
 
            delete this.data;
427
 
        },
428
 
 
429
 
        &#x2F;&#x2F;---------------------------------------------------------------------
430
 
        &#x2F;&#x2F; Test methods - names must begin with &quot;test&quot;
431
 
        &#x2F;&#x2F;---------------------------------------------------------------------
432
 
 
433
 
        testName : function () {
434
 
            var Assert = Y.Assert;
435
 
 
436
 
            Assert.isObject(this.data);
437
 
            Assert.isString(this.data.name);
438
 
            Assert.areEqual(&quot;test&quot;, this.data.name);
439
 
        },
440
 
 
441
 
        testYear : function () {
442
 
            var Assert = Y.Assert;
443
 
 
444
 
            Assert.isObject(this.data);
445
 
            Assert.isNumber(this.data.year);
446
 
            Assert.areEqual(2007, this.data.year);
447
 
        },
448
 
 
449
 
        testBeta : function () {
450
 
            var Assert = Y.Assert;
451
 
 
452
 
            Assert.isObject(this.data);
453
 
            Assert.isBoolean(this.data.beta);
454
 
            Assert.isTrue(this.data.beta);
455
 
        }
456
 
 
457
 
    });
458
 
 
459
 
    Y.example.test.ArrayTestCase = new Y.Test.Case({
460
 
 
461
 
        &#x2F;&#x2F;name of the test case - if not provided, one is auto-generated
462
 
        name : &quot;Array Tests&quot;,
463
 
 
464
 
        &#x2F;&#x2F;---------------------------------------------------------------------
465
 
        &#x2F;&#x2F; setUp and tearDown methods - optional
466
 
        &#x2F;&#x2F;---------------------------------------------------------------------
467
 
 
468
 
        &#x2F;*
469
 
         * Sets up data that is needed by each test.
470
 
         *&#x2F;
471
 
        setUp : function () {
472
 
            this.data = [0,1,2,3,4]
473
 
        },
474
 
 
475
 
        &#x2F;*
476
 
         * Cleans up everything that was created by setUp().
477
 
         *&#x2F;
478
 
        tearDown : function () {
479
 
            delete this.data;
480
 
        },
481
 
 
482
 
        &#x2F;&#x2F;---------------------------------------------------------------------
483
 
        &#x2F;&#x2F; Test methods - names must begin with &quot;test&quot;
484
 
        &#x2F;&#x2F;---------------------------------------------------------------------
485
 
 
486
 
        testPop : function () {
487
 
            var Assert = Y.Assert;
488
 
 
489
 
            var value = this.data.pop();
490
 
 
491
 
            Assert.areEqual(4, this.data.length);
492
 
            Assert.areEqual(4, value);
493
 
        },
494
 
 
495
 
        testPush : function () {
496
 
            var Assert = Y.Assert;
497
 
 
498
 
            this.data.push(5);
499
 
 
500
 
            Assert.areEqual(6, this.data.length);
501
 
            Assert.areEqual(5, this.data[5]);
502
 
        },
503
 
 
504
 
        testSplice : function () {
505
 
            var Assert = Y.Assert;
506
 
 
507
 
            this.data.splice(2, 1, 6, 7);
508
 
 
509
 
            Assert.areEqual(6, this.data.length);
510
 
            Assert.areEqual(6, this.data[2]);
511
 
            Assert.areEqual(7, this.data[3]);
512
 
        }
513
 
 
514
 
    });
515
 
 
516
 
    Y.example.test.ExampleSuite = new Y.Test.Suite(&quot;Example Suite&quot;);
517
 
    Y.example.test.ExampleSuite.add(Y.example.test.DataTestCase);
518
 
    Y.example.test.ExampleSuite.add(Y.example.test.ArrayTestCase);
519
 
 
520
 
    &#x2F;&#x2F;create the console
521
 
    var r = new Y.Console({
522
 
        newestOnTop : false,
523
 
        style: &#x27;block&#x27; &#x2F;&#x2F; to anchor in the example content
524
 
    });
525
 
 
526
 
    r.render(&#x27;#testLogger&#x27;);
527
 
 
528
 
    Y.Test.Runner.add(Y.example.test.ExampleSuite);
529
 
 
530
 
    &#x2F;&#x2F;run the tests
531
 
    Y.Test.Runner.run();
532
 
 
533
 
});
534
 
&lt;&#x2F;script&gt;</pre>
535
 
 
536
 
</div>
537
 
        </div>
538
 
 
539
 
        <div id="sidebar" class="yui3-u">
540
 
            
541
 
                <div id="toc" class="sidebox">
542
 
                    <div class="hd">
543
 
                        <h2 class="no-toc">Table of Contents</h2>
544
 
                    </div>
545
 
 
546
 
                    <div class="bd">
547
 
                        <ul class="toc">
548
 
<li>
549
 
<a href="#simple-test-example">Simple Test Example</a>
550
 
<ul class="toc">
551
 
<li>
552
 
<a href="#creating-the-first-testcase">Creating the first TestCase</a>
553
 
</li>
554
 
<li>
555
 
<a href="#creating-the-second-testcase">Creating the second TestCase</a>
556
 
</li>
557
 
<li>
558
 
<a href="#creating-the-testsuite">Creating the TestSuite</a>
559
 
</li>
560
 
<li>
561
 
<a href="#running-the-tests">Running the tests</a>
562
 
</li>
563
 
</ul>
564
 
</li>
565
 
<li>
566
 
<a href="#complete-example-source">Complete Example Source</a>
567
 
</li>
568
 
</ul>
569
 
                    </div>
570
 
                </div>
571
 
            
572
 
 
573
 
            
574
 
                <div class="sidebox">
575
 
                    <div class="hd">
576
 
                        <h2 class="no-toc">Examples</h2>
577
 
                    </div>
578
 
 
579
 
                    <div class="bd">
580
 
                        <ul class="examples">
581
 
                            
582
 
                                
583
 
                                    <li data-description="Demonstrates basic usage of YUI Test for setting up and running tests.">
584
 
                                        <a href="test-simple-example.html">Simple Testing Example</a>
585
 
                                    </li>
586
 
                                
587
 
                            
588
 
                                
589
 
                                    <li data-description="Demonstrates how to use advanced testing features such as defining tests that should fail, tests that should be ignored, and tests that should throw an error.">
590
 
                                        <a href="test-advanced-test-options.html">Advanced Test Options</a>
591
 
                                    </li>
592
 
                                
593
 
                            
594
 
                                
595
 
                                    <li data-description="Demonstrates how to use the ArrayAssert object to test array data.">
596
 
                                        <a href="test-array-tests.html">Array Processing</a>
597
 
                                    </li>
598
 
                                
599
 
                            
600
 
                                
601
 
                                    <li data-description="Demonstrates basic asynchronous tests.">
602
 
                                        <a href="test-async-test.html">Asynchronous Testing</a>
603
 
                                    </li>
604
 
                                
605
 
                            
606
 
                                
607
 
                                    <li data-description="Demonstrates using events with asynchronous tests.">
608
 
                                        <a href="test-async-event-tests.html">Asynchronous Event Testing</a>
609
 
                                    </li>
610
 
                                
611
 
                            
612
 
                        </ul>
613
 
                    </div>
614
 
                </div>
615
 
            
616
 
 
617
 
            
618
 
        </div>
619
 
    </div>
620
 
</div>
621
 
 
622
 
<script src="../assets/vendor/prettify/prettify-min.js"></script>
623
 
<script>prettyPrint();</script>
624
 
 
625
 
</body>
626
 
</html>