Mozilla code is covered by a large number of automated unit- and regression tests. These tests are run on Tinderbox constantly and developers are expected to make sure their changes do not break the automated test-suites.
Mozilla uses several home-grown automated testing frameworks, an overview of each framework with links to detailed documentation is available at Mozilla automated testing.
This page lists the steps to run the automated tests.
Configuring the build
In order to run most tests, you must have a properly configured build. Platform (Gecko, Toolkit) tests, as well as Firefox-specific tests, are usually run on a Firefox build.
Build Documentation has the general instructions on building Firefox. The default build options are suitable for running the automated tests. The tests can be run on both debug and release builds. To run tests with leak checking you must enable --enable-tracerefcnt or --enable-trace-malloc.
xpcshell/"compiled code" tests
$ make -C $(OBJDIR) xpcshell-tests $ make -C $(OBJDIR) check
Note: on the Gecko 1.9.0 branch (Firefox 3.0), the compiled code and xpcshell-based tests are both run using "make check".
If any of the tests fail, you get a message like:
make: *** [check] Error 2
make exits without an error, all the tests passed.
To run the whole Mochitest suite use the following commands:
$ make -C $(OBJDIR) mochitest-plain $ make -C $(OBJDIR) mochitest-chrome $ make -C $(OBJDIR) mochitest-a11y $ make -C $(OBJDIR) mochitest-ipc-plugins
$ make -C $(OBJDIR) mochitest-plain $ make -C $(OBJDIR) mochitest-chrome $ make -C $(OBJDIR) mochitest-a11y
cd <OBJ_DIR> cd _tests/testing/mochitest python runtests.py --autorun python runtests.py --autorun --chrome python runtests.py --autorun --a11y
The tests may take a while to complete (40 minutes on a 2Ghz Macbook as of June 2008) and the browser window must be focused during the test, otherwise some tests will fail.
See the individual sections on the Mochitest page for more information.
Use the following command to run reftests or crashtests:
$ make -C $(OBJDIR) reftest $ make -C $(OBJDIR) crashtest
Note: on the Gecko 1.9.0 branch (Firefox 3.0), crashtests and reftests must be run manually (and require the creation of a separate profile). See the README.
Reftests take about 20 minutes on the configuration listed above.
If the command prints any output (
UNEXPECTED FAIL or similar), some reftests have failed.
On Windows piping to 'cat' can cause the output to be displayed if it would not otherwise be.
Browser chrome tests
Browser chrome tests can be run in Firefox using the following command:
$ make -C $(OBJDIR) mochitest-browser-chrome
cd <OBJ_DIR> cd _tests/testing/mochitest python runtests.py --browser-chrome --autorun
Other tests not covered in this document