b9jTest A wrapper around YUI Test to make simple testing quick and easy

NAME

b9jTest - A wrapper around YUI Test to make simple testing quick and easy

SYNOPSIS

b9jTest(function(test) {

    test.areEqual("xyzzy", "xyzzy");
    test.areEqual("apple", "apple");
    test.like(/banana/, "banana");

});

YUI VERSION

YUI 2.3.6

DESCRIPTION

b9jTest is a convenience package for running tests. It is comprised of b9jTest.js and b9jTest.css, which include every YUI and b9j component you need to run tests.

DOWNLOAD

Example HTML test document

The following is a functioning example of b9jTest in action:

    <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.like(/banana/, "banana");
        });

    </script>
    </body>
    </html>

Try this example: http://appengine.bravo9.com/b9j/documentation/b9jTest-example.html

METHODS

b9jTest( $function )

Run the given $function with a tester object as the first argument

    b9jTest(function(test) {

        test.areEqual( ... )
        ...

    });

In order to report test results, b9jTest expects to be run in an HTML document that includes an element with the id of "testLogger" wrapped in the "yui-skin-sam" CSS skin:

    <body class="yui-skin-sam">
    <div id="testLogger"></div>
    <script type="text/javascript">

        b9jTest(function(test) {
             ...
        });

    </script>
    </body>

Test functions

The following test functions are available on passed in tester object.

Most of these are wrappers around functions found in the YAHOO.util.Assert package. A detailed description of their workings can be found at: http://developer.yahoo.com/yui/docs/YAHOO.util.Assert.html

areEqual( $want, $have, [ $message ] )

» YAHOO.util.Assert.areEqual

is( $want, $have, [ $message ] )

An alias for areEqual

areNotEqual( $want, $have, [ $message ] )

» YAHOO.util.Assert.areNotEqual

isnt( $want, $have, [ $message ] )

An alias for areNotEqual

like( $re, $value, [ $message ] )

The test passes if $value matches $re (which is a regular expression)

     test.like(/xyzzy/, "applexyzzy")

unlike( $re, $value, [ $message ] )

The test passes if $value does NOT match $re (which is a regular expression)

     test.unlike(/xyzzy/, "banana")

areSame( $want, $have, [ $message ] )

» YAHOO.util.Assert.areSame

areNotSame( $want, $have, [ $message ] )

» YAHOO.util.Assert.areNotSame

fail( [ $message ] )

» YAHOO.util.Assert.fail

isTypeOf( $wantType, $value, [ $message ] )

» YAHOO.util.Assert.isTypeOf

isArray( $have, [ $message ] )

» YAHOO.util.Assert.isArray

isBoolean( $have, [ $message ] )

» YAHOO.util.Assert.isBoolean

isFunction( $have, [ $message ] )

» YAHOO.util.Assert.isFunction

isNumber( $have, [ $message ] )

» YAHOO.util.Assert.isNumber

isOjbect( $have, [ $message ] )

» YAHOO.util.Assert.isObject

isString( $have, [ $message ] )

» YAHOO.util.Assert.isString

isTrue( $have, [ $message ] )

» YAHOO.util.Assert.isTrue

isFalse( $have, [ $message ] )

» YAHOO.util.Assert.isFalse

isNaN( $have, [ $message ] )

» YAHOO.util.Assert.isNaN

isNotNaN( $have, [ $message ] )

» YAHOO.util.Assert.isNotNaN

isNull( $have, [ $message ] )

» YAHOO.util.Assert.isNull

isNotNull( $have, [ $message ] )

» YAHOO.util.Assert.isNotNull

isUndefined( $have, [ $message ] )

» YAHOO.util.Assert.isUndefined

isNotUndefined( $have, [ $message ] )

» YAHOO.util.Assert.isNotUndefined

SEE ALSO

YUI Test

JS-Test-Simple

JSUnit

b9j - A JavaScript toolkit

AUTHOR

Robert Krimen <robertkrimen at gmail.com> http://bravo9.com

DOWNLOAD

Available as part of b9j: b9j-latest.zip

SOURCE

You can contribute or fork this project via GitHub:

http://github.com/robertkrimen/b9j/tree/master

 git clone git://github.com/robertkrimen/b9j.git

COPYRIGHT & LICENSE

Copyright 2008 Robert Krimen

Code licensed under the BSD License: http://appengine.bravo9.com/b9j/documentation/license.txt