b9jTest - A wrapper around YUI Test to make simple testing quick and easy
b9jTest(function(test) {
test.areEqual("xyzzy", "xyzzy");
test.areEqual("apple", "apple");
test.like(/banana/, "banana");
});
YUI 2.3.6
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.
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
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>
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
An alias for areEqual
» YAHOO.util.Assert.areNotEqual
An alias for areNotEqual
The test passes if $value matches $re (which is a regular expression)
test.like(/xyzzy/, "applexyzzy")
The test passes if $value does NOT match $re (which is a regular expression)
test.unlike(/xyzzy/, "banana")
» YAHOO.util.Assert.areNotSame
» YAHOO.util.Assert.isFunction
» YAHOO.util.Assert.isUndefined
» YAHOO.util.Assert.isNotUndefined
b9j - A JavaScript toolkit
Robert Krimen <robertkrimen at gmail.com> http://bravo9.com
Available as part of b9j: b9j-latest.zip
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 2008 Robert Krimen
Code licensed under the BSD License: http://appengine.bravo9.com/b9j/documentation/license.txt