[jQuery] jQuery test suite and jsUnit compatibility

[jQuery] jQuery test suite and jsUnit compatibility

Hi all,
On the Fluid Project, we have been using Edward Hieatt's jsUnit (http://www.jsunit.net/
) for unit testing all of our code. A number of problems--including
the inability to use Firebug to debug failing tests--caused us to look
elsewhere for a less intrusive JavaScript testing framework.
The jQuery testing suite is great! I've ported all of my tests over to
it, and have been really happy with the results. Along with this,
I've made some simple extensions to the jQuery testing suite (which
I've started calling "jqUnit" for convenience) that I wanted to share
with the wider community and get your feedback.
First of all, I've attached a patch to testrunner.js, which moves all
its functions into a closure for privacy and exposes the public test
API within a namespace called "jqUnit." This will help avoid conflicts
in the global namespace. Since I pass $ in as an argument, it also
ensures that we don't have any problems in noConflicts mode.
This patch isn't an example of beautiful refactoring, but I wanted to
favour clarity--if people find this interesting, I can clean up the
code and indenting.
Secondly, I've written a number of adaptor functions to provide
compatibility for my old jsUnit tests. These provide xUnit-style
asserts, and are just wrappers around the underlying jQuery assert
functions such as ok(). Perhaps these are useful for others who are
porting from jsUnit?
Lastly, I've added support for setUp() and tearDown() functions which
get run before and after each test. I've created a simple object
called TestCase. Its constructor takes three arguments: the module's
name, your setUp function, and your tearDown function.
Is this useful to anyone?
Colin

---
Colin Clark
Technical Lead, Fluid Project
http://fluidproject.org