I've been recently working with John Resig on his great Firebug extension called Fireunit. This very promising extension is intended as an automated testing framework for Firefox extensions and it should also be useful for testing web pages in the future. It's still at the beginning, but growing and starting to be very useful for testing Firebug itself.
Such unit test framework is what I have been waiting for a long time. Not only debugging and profiling is important and the unit testing was the missing piece in the Firebug world.
My goal was to improve Fireunit's UI and make the output more transparent for users. Let's take a quick look how it looks now.
As you can see Fireunit brings a new Test panel that displays list of results from executed tests. Each entry is expandable so, some additional info about particular message can be discovered.
Since Fireunit's APIs allow to compare expected and actual state of the UI (HTML in most cases), there can be even additional info tab displaying if the message comes from this kind of test.
Running a test is as simple as navigating your browser to a test page. Try an empty example test here (sure you need Fireunit). Once the test finishes the Test panel should be displaying two passing and two failing tests.
The test page looks like as follows.
fireunit.ok(true, "Passing test result");
fireunit.ok(false, "Failing test result.");
fireunit.compare("expected data", "expected data",
"Passing verification of expected and actual input.");
"Failing verification of expected and actual input.");
// Wait for asynchronous operation.
// Finish test
Tests for Firebug
I have also written some tests intended for Firebug's Net panel. If you want to run them just go to Firebug's SVN repository, download entire svn/tests/unit directory onto your local hard drive and navigate your browser to start.html file (using file: protocol). This file represents a test-suite, which automatically runs all the tests in the net directory (you can also try startScript.html file that runs one test for Script panel). Don't forget to enable Net (Script) panel, the test suite doesn't do it automatically yet.
Notice that these tests access chrome (in order to verify Firebug's UI) and so, you have to set following preference.
Fireunit uses local HTTP server for tests that need to simulate network communication. If you want to avoid dialog asking for permissions (the first time) you can also set:
If you want to install Fireunit, I recommend Firebug 1.3b6 or Firebug 1.4a10. If you choose version with tracing console enabled, you can also see some logs generated from running tests (don't forget to check FIREUNIT option).