Running automated tests

  • Revision slug: Running_automated_tests
  • Revision title: Running automated tests
  • Revision id: 5232
  • Created:
  • Creator: khuey
  • Is current revision? No
  • Comment 66 words added, 30 words removed

Revision Content

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

The following commands execute the standalone (aka "compiled-code") tests and the xpcshell-based 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

If make exits without an error, all the tests passed.

Mochitest

To run the whole Mochitest suite use the following commands:

1.9.2.4+:

$ make -C $(OBJDIR) mochitest-plain
$ make -C $(OBJDIR) mochitest-chrome
$ make -C $(OBJDIR) mochitest-a11y
$ make -C $(OBJDIR) mochitest-ipc-plugins

1.9.1:

$ make -C $(OBJDIR) mochitest-plain
$ make -C $(OBJDIR) mochitest-chrome
$ make -C $(OBJDIR) mochitest-a11y

1.9.0:

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.

Reftest/crashtests

Use the following command to run reftests or crashtests:

1.9.1+:

$ 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:

1.9.1+:

$ make -C $(OBJDIR) mochitest-browser-chrome

1.9.0:

cd <OBJ_DIR>
cd _tests/testing/mochitest
python runtests.py --browser-chrome --autorun

Other tests not covered in this document

  • Tinderbox performance tests - Tp, Txul, Ts, etc.
  • Talos
  • running the above tests with/without leak, assertion checks

Revision Source

<p>Mozilla code is covered by a large number of automated unit- and regression tests. These tests are run on <a href="/en/Tinderbox" title="en/Tinderbox">Tinderbox</a> constantly and developers are expected to make sure their changes do not break the automated test-suites.</p>
<p>Mozilla uses several home-grown automated testing frameworks, an overview of each framework with links to detailed documentation is available at <a href="/en/Mozilla_automated_testing" title="en/Mozilla_automated_testing">Mozilla automated testing</a>.</p>
<p>This page lists the steps to run the automated tests.</p>
<h3 name="Configuring_the_build">Configuring the build</h3>
<p>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.</p>
<p><a href="/En/Developer_Guide/Build_Instructions" title="en/Build_Documentation">Build Documentation</a> 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.</p>
<h3 name="make_check"><code>xpcshell/"compiled code" tests<br>
</code></h3>
<p>The following commands execute the <a href="/en/Compiled-code_automated_tests" title="en/Compiled-code_automated_tests">standalone (aka "compiled-code") tests</a> and the <a href="/en/Writing_xpcshell-based_unit_tests" title="en/Writing_xpcshell-based_unit_tests">xpcshell-based tests</a>.</p>
<pre class="eval">$ make -C $(OBJDIR) xpcshell-tests
$ make -C $(OBJDIR) check
</pre>
<p>Note: on the Gecko 1.9.0 branch (Firefox 3.0), the compiled code and xpcshell-based tests are both run using "make check".</p>
<p>If any of the tests fail, you get a message like:</p>
<pre class="eval">make: *** [check] Error 2
</pre>
<p>If <code>make</code> exits without an error, all the tests passed.</p>
<h3 name="Mochitest">Mochitest</h3>
<p>To run the whole <a href="/en/Mochitest" title="en/Mochitest">Mochitest</a> suite use the following commands:</p>
<p>1.9.2.4+:</p>
<pre class="eval">$ make -C $(OBJDIR) mochitest-plain
$ make -C $(OBJDIR) mochitest-chrome
$ make -C $(OBJDIR) mochitest-a11y
$ make -C $(OBJDIR) mochitest-ipc-plugins
</pre>
<p>1.9.1:</p>
<pre class="eval">$ make -C $(OBJDIR) mochitest-plain
$ make -C $(OBJDIR) mochitest-chrome
$ make -C $(OBJDIR) mochitest-a11y</pre>
<p>1.9.0:</p>
<pre class="eval">cd <strong>&lt;OBJ_DIR&gt;</strong>
cd _tests/testing/mochitest
python runtests.py --autorun
python runtests.py --autorun --chrome
python runtests.py --autorun --a11y 
</pre>
<p>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.</p>
<p>See the individual sections on the <a href="/en/Mochitest" title="en/Mochitest">Mochitest</a> page for more information.</p>
<h3 name="Reftests">Reftest/crashtests</h3>
<p>Use the following command to run reftests or crashtests:</p>
<p>1.9.1+:</p>
<pre class="eval">$ make -C $(OBJDIR) reftest
$ make -C $(OBJDIR) crashtest
</pre>
<p>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 <a class="external" href="http://mxr.mozilla.org/mozilla-central/source/layout/tools/reftest/README.txt" title="http://mxr.mozilla.org/mozilla-central/source/layout/tools/reftest/README.txt">README</a>.</p>
<p>Reftests take about 20 minutes on the configuration listed above.</p>
<p>If the command prints any output (<code>UNEXPECTED FAIL</code> or similar), some reftests have failed.</p>
<p>On Windows piping to 'cat' can cause the output to be displayed if it would not otherwise be.</p>
<h3>Browser chrome tests</h3>
<p><a class="internal" href="/en/Browser_chrome_tests" title="en/Browser chrome tests">Browser chrome tests</a> can be run in Firefox using the following command:</p>
<p>1.9.1+:</p>
<pre class="eval">$ make -C $(OBJDIR) mochitest-browser-chrome
</pre>
<p>1.9.0:</p>
<pre class="eval">cd <strong>&lt;OBJ_DIR&gt;</strong>
cd _tests/testing/mochitest
python runtests.py --browser-chrome --autorun
</pre>
<p>Other tests not covered in this document</p>
<ul> <li>Tinderbox performance tests - Tp, Txul, Ts, etc. <a class="external" href="http://wiki.mozilla.org/Performance:Tinderbox_Tests"></a></li> <li>Talos</li> <li>running the above tests with/without leak, assertion checks</li>
</ul>
Revert to this revision