Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

grink (8549)

grink
  (email not shown publicly)

Journal of grink (8549)

Tuesday August 26, 2008
06:22 PM

b9jTest: Simplifying and enhancing YUI Test

[ #37279 ]

YUI Test is a great tool for javascript testing, but it has a couple of small issues:

  • Setting up the HTML document requires many different .js and .css assets
  • The actual javascript code to set up the test environment is not trivial (setting up the TestRunner, setting up the TestLogger, etc.)
  • A failed assertion will abort the test function immediately, preventing later tests from running

b9jTest addresses the problems above by:

  • Bundling all the required .js and .css assets into just two separate files
  • Providing some boilerplate javascript so you can jump right into testing without a lot of setup

An example b9jTest document:

<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>b9jTest example</title>
<link rel="stylesheet" type="text/css"
    href="http://appengine.bravo9.com/b9j/b9jTest.css">
<script type="text/javascript"
    src="http://appengine.bravo9.com/b9j/b9jTest.js"></script>
</head>
<body class="yui-skin-sam">
<div id="testLogger"></div>
<script type="text/javascript">

    b9jTest(function(test) {
        test.areEqual("xyzzy", "xyzzy");
        test.areEqual("apple", "apple");
        test.areEqual("banana", "banana");
    });  

</script>
</body>

b9jTest() is a global function that accepts a function that is called with a testing object. The testing object provides access to the standard YUI assertions and more.

Documentation:

Download:

b9jTest: Simplifying and enhancing YUI Test

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.