Running automated tests

  • Revision slug: Running_automated_tests
  • Revision title: Running automated tests
  • Revision id: 5220
  • Created:
  • Creator: Nickolay
  • Is current revision? No
  • Comment [[Running Mozilla Tests]] moved to [[Running automated tests]]

Revision Content

In order to run most tests, one should have built a copy of Firefox which was built within certain flags are set. Some tests can be run on a regular "as shipped" copy of Firefox, but one may not be able to see any output. It is usually just better to build the application.

See Build Documentation for instructions on building Firefox. One can use these flags in the browser/config/mozconfig file:

mk_add_options MOZ_CO_PROJECT=browser
ac_add_options --enable-debug
ac_add_options --enable-application=browser
ac_add_options --enable-test
ac_add_options --enable-mochitest

Other flags that may be needed to run some of the tests (YMMV) are:

ac_add_options --enable-gtktest
ac_add_options --enable-libIDLtest
ac_add_options --enable-glibtest

Standalone Tests

Once one has built Firefox with these options, there is a dist/ directory. This is one place to start. In the dist/bin/ directory, one will find links to executables that start with "Test". Some of these come with instructions, and some do not.

% cd dist/bin
%
% ls Test*
TestAutoPtr@                    TestCookie@                     TestIncrementalDownload@        TestParser@                     TestTXMgr@
TestBlockingSocket@             TestDNS@                        TestLineBreak@                  TestServ@                       TestURLParser@
TestCOMPtr@                     TestFactory@                    TestMinStringAPI@               TestServMgr@                    TestUpload@
TestCOMPtrEq@                   TestHashtables@                 TestObserverService@            TestStandardURL@                TestVersionComparator@
TestCallTemplates@              TestID@                         TestOpen@                       TestStreamConv@                 TestXMLExtras@
TestCallbacks@                  TestINIParser@                  TestPageLoad@                   TestStreamLoader@               TestXPC@
%
% ./TestBlockingSocket
usage: ./TestBlockingSocket <host> <port> <file-to-read>
%
% ./TestID
%

MochiTests

If a _tests/ directory exists under the top-level source directory, then the MochiTests have been built. In order to run them, one can run:

% cd _tests/testing/mochitest
%
% sh
$ perl ./runtests.pl --autorun --close-when-done --appname=<executable> --console-level=INFO | grep '^REFTEST '
...
$ perl ./runtests.pl --autorun --close-when-done --appname=<executable> --console-level=INFO -chrome | grep '^REFTEST '
...
$ exit
%

Reftests

% sh
$
$ <executable> --reftest layout/reftests/reftest.list
...
$ exit
%

Revision Source

<p>In order to run most tests, one should have built a copy of Firefox which was built within certain flags are set. Some tests can be run on a regular "as shipped" copy of Firefox, but one may not be able to see any output. It is usually just better to build the application.
</p><p>See <a href="en/Build_Documentation">Build Documentation</a> for instructions on building Firefox. One can use these flags in the browser/config/mozconfig file:
</p>
<pre>mk_add_options MOZ_CO_PROJECT=browser
ac_add_options --enable-debug
ac_add_options --enable-application=browser
ac_add_options --enable-test
ac_add_options --enable-mochitest
</pre>
<p>Other flags that may be needed to run some of the tests (YMMV) are:
</p>
<pre>ac_add_options --enable-gtktest
ac_add_options --enable-libIDLtest
ac_add_options --enable-glibtest
</pre>
<h3 name="Standalone_Tests"> Standalone Tests </h3>
<p>Once one has built Firefox with these options, there is a <code>dist/</code> directory. This is one place to start. In the <code>dist/bin/</code> directory, one will find links to executables that start with "Test". Some of these come with instructions, and some do not.
</p>
<pre>% cd dist/bin
%
% ls Test*
TestAutoPtr@                    TestCookie@                     TestIncrementalDownload@        TestParser@                     TestTXMgr@
TestBlockingSocket@             TestDNS@                        TestLineBreak@                  TestServ@                       TestURLParser@
TestCOMPtr@                     TestFactory@                    TestMinStringAPI@               TestServMgr@                    TestUpload@
TestCOMPtrEq@                   TestHashtables@                 TestObserverService@            TestStandardURL@                TestVersionComparator@
TestCallTemplates@              TestID@                         TestOpen@                       TestStreamConv@                 TestXMLExtras@
TestCallbacks@                  TestINIParser@                  TestPageLoad@                   TestStreamLoader@               TestXPC@
%
% ./TestBlockingSocket
usage: ./TestBlockingSocket &lt;host&gt; &lt;port&gt; &lt;file-to-read&gt;
%
% ./TestID
%
</pre>
<h3 name="MochiTests"> MochiTests </h3>
<p>If a <code>_tests/</code> directory exists under the top-level source directory, then the MochiTests have been built. In order to run them, one can run:
</p>
<pre>% cd _tests/testing/mochitest
%
% sh
$ perl ./runtests.pl --autorun --close-when-done --appname=&lt;executable&gt; --console-level=INFO | grep '^REFTEST '
...
$ perl ./runtests.pl --autorun --close-when-done --appname=&lt;executable&gt; --console-level=INFO -chrome | grep '^REFTEST '
...
$ exit
%
</pre>
<h3 name="Reftests"> Reftests </h3>
<pre>% sh
$
$ &lt;executable&gt; --reftest layout/reftests/reftest.list
...
$ exit
%
</pre>
Revert to this revision