I love unit testing, especially for JavaScript, which is why I wrote YUI Test. John Resig just announced another exciting tool for unit testing called FireUnit. FireUnit is an extension to Firebug (1.2+) and adds another tab to the Firebug console in which test results are output. Also included is a small JavaScript API for outputting results onto the Test tab.

When I wrote YUI Test, I made sure that the TestRunner object was completely event-driven so that test results could be output in any way that made sense. To prove how easy it is to create your own visualization for YUI Test results, I created a FireUnit extension for YUI Test. The extension is nothing exciting, just a simple JavaScript object that subscribes to the various TestRunner events and then marshals them to the appropriate FireUnit API calls. All you need to do is load the file and include the following line of code:

YAHOO.tool.FireUnit.attach();

That’s it! All the results will be output to the Test tab in Firebug. There are some limitations to FireUnit, such as its inability to group tests and a lack of anything but basic result formatting (so some of the failure messages YUI Test generates don’t look all that pretty). Still, it’s a step in the right direction and I’m sure John will be continuing to develop it. Feel free to download FireUnit for YUI Test and give it a whirl (BSD license).

Disclaimer: Any viewpoints and opinions expressed in this article are those of Nicholas C. Zakas and do not, in any way, reflect those of my employer, my colleagues, Wrox Publishing, O'Reilly Publishing, or anyone else. I speak only for myself, not for them.

Both comments and pings are currently closed.