My favorites | Sign in
Project Logo
                
Search
for
Updated Dec 02, 2008 by mikeal.rogers
JavascriptUnittestModule  
Documents the jum (JavaScript Unittest Module)

Example

var jum = {}; Components.utils.import('resource://mozmill/modules/jum.js', jum);

var testAsserts = function() {
  jum.assert(true);
  jum.assertTrue(true);
  jum.assertFalse(false);
  jum.assertEquals('asdf', 'asdf');
  jum.assertNotEquals('asdf', 'fdsa');
  jum.assertNull(null);
  jum.assertNotNull(true);
  jum.assertUndefined({}.asdf);
  jum.assertNotUndefined('asdf');
  jum.assertNaN('a');
  jum.assertNotNaN(4);
  jum.pass();
}

var testNotAsserts = function() {
  // All these calls will fail.
  jum.assert(false);
  jum.assertTrue(false);
  jum.assertTrue('asf');
  jum.assertFalse(true);
  jum.assertFalse('asdf');
  jum.assertEquals('asdf', 'fdsa');
  jum.assertNotEquals('asdf', 'asdf');
  jum.assertNull(true);
  jum.assertNotNull(null);
  jum.assertUndefined('asdf');
  jum.assertNotUndefined({}.asdf);
  jum.assertNaN(4);
  jum.assertNotNaN('f');
  jum.fail();
}

The jum module is incredibly simple. It allows you to use a series of assert calls that will trigger failures in the mozmill test framework. Unlike MozMill's functional test API these do not trigger exceptions and as such can be called consecutively in a test function even after a failure.

All of these calls also accept an optional comment argument. This argument will be seen in the test failure log. Strings are recommended but any JSON serializable object should work.

jum.assert(false, "This is an example")

Sign in to add a comment
Hosted by Google Code