Examining the Scriptaclous Unit Testing Implementation

1: Tackling the Code

First, what documentation exists on the scriptaculous unit testing code?

http://wiki.script.aculo.us/scriptaculous/show/UnitTesting general

Specific to the central class, Test.Unit.Runner:

It's a little bare, isn't it? We're going to have to read the code to find out what's really going on.

Let's pretend, for a moment, that you aren't a JavaScript expert. I am not a JavaScript expert either, so you're in friendly company.

Now let's tackle the code.

From the documentation example:

  // test cases follow, each method which starts 
  // with "test" is considered a test case
  testATest: function() { with(this) {
    // code

Here's an actual test from Scriptaculous, in test/unti/string_test.html.

  new Test.Unit.Runner({
    testStringParseColor: function() { with(this) {
      assertEqual('#000000', "#000000".parseColor());
      assertEqual('#000000', "rgb(0,0,0)".parseColor());

The new Test.Unit.Runner calls the constructor assigned to the symbol Test.Unit.Runner. This line should return an object because "new" is an expression that returns an object. One can't help but notice, however, that nothing seems to be done with any created object, at least not in this code. It isn't even assigned to a variable--it remains anonymous. What's going on here?

I better dig deeper.