Fully namespaced, debuggable unit tests

Colin Clark colin.clark at utoronto.ca
Sun Feb 24 20:13:01 UTC 2008

Hi everyone,

We've been struggling for awhile now with jsUnit, a testing framework  
for in-browser JavaScript unit tests. We have hundreds of jsUnit tests  
for all of Fluid's code. It provides a familiar xUnit-style  
environment for writing tests, but it imposed some really frustrating  
restrictions including:

  * Inability to put unit test code into a private namespace
  * The Firebug debugger simply won't work with it

Trying to debug tests without a solid debugger is, as you can imagine,  
slow and frustrating. After fighting with it for too long, I finally  
decided to do some research and get rid of jsUnit altogether.

There are a lot of half-baked JavaScript testing frameworks out there.  
None of them are perfect, but the least broken amongst them seems be-- 
no surprise here--the one written by John Resig for testing jQuery. I  
had a fairly painless time porting my tests to this framework, which  
I've dubbed "jqUnit." In the process, I wrote a number of adaptor  
functions that make it much easier to port over old jsUnit tests:


In the process, the unit tests for my jQuery keyboard accessibility  
plugin are fully debuggable with Firebug and totally self-contained in  
their own namespace!


Given this experience, I hope we'll be porting the Reorderer's large  
suite of unit tests over as soon as we've finished our current round  
of development.


Colin Clark
Technical Lead, Fluid Project
Adaptive Technology Resource Centre, University of Toronto

More information about the fluid-work mailing list