Changes

Jump to: navigation, search

Real World Mozilla Unit Testing Lab

710 bytes added, 15:26, 13 April 2007
no edit summary
[[Dive into Real World Mozilla]] > [[Dive into Real World Mozilla Day 4]] > Mozilla Unit Testing Lab
== Overview ==
$ cd mozilla/''objdir''
$ ../build/autoconf/make-makefile extensions/firstxpcom
$ cd extensions/firstxpcom
$ make
* Write you your JavaScript unit tests for your FirstXpcom component in '''mozilla/extensions/firstxpcom/test/unit/test_firstxpcom.js''':
function run_test() {
$ cd mozilla/''objdir''/extensions/firstxpcom
$ make check
 
* You can safely delete '''mozilla/extensions/firstxpcom/test/unit/test_sample.js''', as it is just an example of basic tests you can run:
 
/* This is the most basic testcase. It makes some trivial assertions,
* then sets a timeout, and exits the test harness when that timeout
* fires. This is meant to demonstrate that there is a complete event
* system available to test scripts.
* Available functions are described at:
* http://developer.mozilla.org/en/docs/Writing_xpcshell-based_unit_tests
*/
function run_test() {
do_check_eq(57, 57)
do_check_neq(1, 2)
do_check_true(true);
do_test_pending();
do_timeout(100, "do_test_finished();");
}
== Resources ==
* [http://developer.mozilla.org/en/docs/Creating_reftest-based_unit_tests Creating reftest-based tests]
* [http://lxr.mozilla.org/seamonkey/source/browser/components/places/tests/ Examples of good xpcshell tests, from mozilla/browser/components/places/tests]
* [https://bugzilla.mozilla.org/show_bug.cgi?id=371329 bug Bug 371329]

Navigation menu