Mozilla automated testing

  • Revision slug: Mozilla_automated_testing
  • Revision title: Mozilla automated testing
  • Revision id: 4101
  • Created:
  • Creator: Nickolay
  • Is current revision? No
  • Comment

Revision Content

When finished, this page will give an overview of options for automated testing available to Mozilla developers with links to more documentation.

Most automated tests are executed on <tt>make check</tt>. How to add a build-time test describes the steps required to add an arbitrary test program to the test suite. Depending on what you need to test, you can use one of the testing frameworks available:

  • With xpcshell test harness you write your unit test in JavaScript. The code later runs in xpcshell, which is an XPConnect-enabled JS shell. This means your code can access XPCOM components, but can't (easily) open windows, test the application's chrome, work with HTML parser or the DOM.
  • You can write standalone test programs in C/C++. This option can be used to test functionality not exposed via XPCOM.
    • {{template.Bug(343673)}} tracks one person's effort, but there has been no recent activity
    • {{template.Bug(346703)}} contains one example of how this might be done
  • JSUnit can be used to write tests that run as content in the browser. Particularly useful for DOM, parser tests, but can't do anything that requires chrome privileges.
    • jsunit will most likely not be a make check target for the time being, since it needs a full browser instance
    • {{mediawiki.interwiki('wikimo', 'SoftwareTesting#Ideas to Collect', 'wikimo:SoftwareTesting#Ideas_to_Collect')}} lists some jsunit examples.
  • jssh for running JavaScript code as chrome.
    • Rumored to be slow
      • What is the source of these rumors?
    • requires an extension to be enabled at build time.
      • works only on trunk. needs to be post-branching merged back to 18
      • {{template.Bug(343199)}} has the patches to build jssh as a real extension
  • {{wiki.template('Named-source', [ "layout/tools/reftest/README.txt", "Layout Engine Visual Tests (reftest)" ])}}. Each test consists of two documents (e.g. HTML) - one of them containing test markup and the other containing reference markup. The system works by comparing the rendering of two documents.
    • How does one run these tests? - instructions are in the README file and {{template.Bug(344591)}}
  • Please ignore the {{mediawiki.interwiki('wikimo', 'SoftwareTesting:Scratchpad', 'wikimo:SoftwareTesting:Scratchpad')}} page, and look at {{mediawiki.interwiki('wikimo', 'SoftwareTesting', 'wikimo:SoftwareTesting')}} only. The scratchpad is for works-in-progress, and is pretty much guaranteed to be stale or wrong.

There's also {{mediawiki.interwiki('wikimo', 'SoftwareTesting', 'wikimo:SoftwareTesting')}} and Automated testing tips and tricks if you're looking for something to read.

Revision Source

<p>
</p><p>When finished, this page will give an overview of options for automated testing available to Mozilla developers with links to more documentation.
</p><p>Most automated tests are executed on <tt>make check</tt>. <a href="en/How_to_add_a_build-time_test">How to add a build-time test</a> describes the steps required to add an arbitrary test program to the test suite. Depending on what you need to test, you can use one of the testing frameworks available:
</p>
<ul><li> With <a href="en/Writing_xpcshell-based_unit_tests">xpcshell test harness</a> you write your unit test in JavaScript. The code later runs in <a href="en/Xpcshell">xpcshell</a>, which is an <a href="en/XPConnect">XPConnect</a>-enabled JS shell. This means your code can access XPCOM components, but can't (easily) open windows, test the application's chrome, work with HTML parser or the DOM.
</li><li> You can write standalone test programs in C/C++. This option can be used to test functionality not exposed via XPCOM. 
<ul><li> <i>{{template.Bug(343673)}} tracks one person's effort, but there has been no recent activity</i>
</li><li> <i>{{template.Bug(346703)}} contains one example of how this might be done</i>
</li></ul>
</li><li> <a class="external" href="http://www.jsunit.net/">JSUnit</a> can be used to write tests that run as content in the browser. Particularly useful for DOM, parser tests, but can't do anything that requires chrome privileges. 
<ul><li> jsunit will most likely not be a make check target for the time being, since it needs a full browser instance
</li><li> {{mediawiki.interwiki('wikimo', 'SoftwareTesting#Ideas to Collect', 'wikimo:SoftwareTesting#Ideas_to_Collect')}} lists some jsunit examples.
</li></ul>
</li><li> jssh for running JavaScript code as chrome.
<ul><li> Rumored to be slow
<ul><li> <i>What is the source of these rumors?</i>
</li></ul>
</li><li> requires an extension to be enabled at build time.
<ul><li> works only on trunk.  needs to be post-branching merged back to 18
</li><li> {{template.Bug(343199)}} has the patches to build jssh as a real extension
</li></ul>
</li></ul>
</li><li> {{wiki.template('Named-source', [ "layout/tools/reftest/README.txt", "Layout Engine Visual Tests (reftest)" ])}}. Each test consists of two documents (e.g. HTML) - one of them containing test markup and the other containing reference markup. The system works by comparing the rendering of two documents.
<ul><li> <i>How does one run these tests?</i> - instructions are in the README file and {{template.Bug(344591)}}
</li></ul>
</li><li> Please ignore the {{mediawiki.interwiki('wikimo', 'SoftwareTesting:Scratchpad', 'wikimo:SoftwareTesting:Scratchpad')}} page, and look at {{mediawiki.interwiki('wikimo', 'SoftwareTesting', 'wikimo:SoftwareTesting')}} only.  The scratchpad is for works-in-progress, and is pretty much guaranteed to be stale or wrong.
</li></ul>
<p>There's also {{mediawiki.interwiki('wikimo', 'SoftwareTesting', 'wikimo:SoftwareTesting')}} and <a href="en/Automated_testing_tips_and_tricks">Automated testing tips and tricks</a> if you're looking for something to read.
</p>
Revert to this revision