Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Mozmill Unit Test Framework

Note: The JUM module has been dropped in Mozmill 2.0. Please make use of the assertions API instead.

The JUM API is basically a group of assertion methods to allow you to throw customized errors during testing.  It is intended to be used for unit testing in Javascript.  To use the JUM API, you need to include jum.js in each test file.  You can do this similarly to how you include the Mozmill API:

 

var jumlib = {};

Components.utils.import("resource://mozmill/modules/jum.js", jumlib);

 

With this in place, you can simply call any of the methods we will talk about here using jumlib.method();  It should be noted that using these asserts will "silently" fail (i.e. They will not break from the function like the asserts of the Controller API).

Without further adieu, I give you the methods...

 

jumlib.assert(boolean, comment)

  • This method will throw a pass or fail based on boolean and use comment as the message
  • boolean: can be either true or false
  • comment: the message to be displayed when the assertion is thrown

 

jumlib.assertTrue(boolean, comment)

  • This method will throw pass or fail based on boolean and use comment as the message
  • If boolean is true, the assertion will pass
  • If boolean is false, the assertion will fail

 

jumlib.assertFalse(boolean, comment)

  • This method will throw pass or fail based on boolean and use comment as the message
  • If boolean is true, the assertion will fail
  • If boolean is false, the assertion will pass

 

jumlib.assertEquals(value1, value2, comment)

  • This method compares the two values and throws pass or fail based on their equality and use comment as the message
  • If value1 and value2 are equal, the assertion will pass
  • If value1 and value2 are inequal, the assertion will fail

 

jumlib.assertNotEquals(value1, value2, comment)

  • This method compares the two values and throws a pass or fail based on their equality and uses comment as the message
  • If value1 and value2 are inequal, the assertion will pass
  • If value1 and value2 are equal, the assertion will fail

 

jumlib.assertNull(value, comment)

  • This method checks whether value is null and uses comment as the message
  • If value is null, the assertion will pass
  • If value is not null, the assertion will fail

 

jumlib.assertNotNull(value, comment)

  • This method checks whether value is not null and uses comment as the message
  • If value is not null, the assertion will pass
  • If value is null, the assertion will fail

 

jumlib.assertUndefined(value, comment)

  • This method checks whether value is undefined and uses comment as the message
  • If value is undefined, the assertion will pass
  • If value is defined, the assertion will fail

 

jumlib.assertNotUndefined(value, comment)

  • This method checks whether value is defined and uses comment as the message
  • If value is defined, the assertion will pass
  • If value is undefined, the assertion will fail

 

jumlib.assertNaN(value, comment)

  • This method checks whether value is not a number and uses comment as the message
  • If value is not a number, the assertion will pass
  • If value is a number, the assertion will fail

 

jumlib.assertNotNaN(value, comment)

  • This method checks whether value is a number and uses comment as the message
  • If value is a number, the assertion will pass
  • If value is not a number, the assertion will fail

 

jumlib.fail()

  • This method throws a fail assertion and returns false

 

jumlib.pass()

  • This method throws a pass assertion and returns true

Document Tags and Contributors

Tags: 
 Contributors to this page: teoli, Ctalbert, Whimboo, lgreco
 Last updated by: Whimboo,