Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 940509 of Testing the Add-on SDK

  • Revision slug: Mozilla/Add-ons/SDK/Guides/Testing_the_Add-on_SDK
  • Revision title: Testing the Add-on SDK
  • Revision id: 940509
  • Created:
  • Creator: konyx
  • Is current revision? No
  • Comment

Revision Content

From Add-on SDK repository

With a checkout of the mozilla/addon-sdk repository (or a checkout of the m-c repo and cd into the addon-sdk/source directory) there are many means to run the addon-sdk tests.

With CFX

CFX tests use the deprecated sdk/loader/cuddlefish, which is being replaced by toolkit/loader.

With cfx (which is part of the addon-sdk repo), we can run the first test suite which was produced for the Add-on SDK.  This includes:

  • cfx testcfx: a suite of python tests which test cfx itself (which is written in python).  This suite basically tests cfx xpi's ability to produce the xpi files that we expect it to.
  • cfx testex --filter <addon_example_folder_name>: a suite of tests which run test code for some example add-ons.   This suite builds the example code, then runs these example add-on's test code.
  • cfx testaddons --filter <addon_folder_name>: a suite of tests which run add-ons, which are themseleves tests.  This suite builds add-ons which are tests (ie: their main.js script's merely run tests and close firefox when their tests are done), and runs them as cfx run would.
  • cfx testpkgs --filter <file_name>:<test_name>: a suite of tests which run sdk module unit tests.  This suite builds the entire addon-sdk repo as an add-on, like cfx xpi would, then runs the add-on like cfx test would.  The majority of the tests run here are module unit tests, but there are various other tests included here as well.

Note: You must remember to run source bin/activate in order to enable cfx first.

With JPM

JPM tests all use the new toolkit/loader.

Wtih jpm (which is not part of the add-on sdk repo, and must be installed separately) things more difficult without the Gulp commands provided by the gulpscript.js file in the addon-sdk repo.  With gulp installed, and after installing the addon-sdk's npm dependencies, we can run the latter three test suites mentioned for cfx with jpm using the following commands:

  • gulp test:examples --filter <addon_example_folder_name>
  • gulp test:addons --filter <addon_folder_name>
  • gulp test:modules --filter <file_name>:<test_name>

or run all of the tests with gulp test.

With Travis

If you merely make a pull request for the mozilla/addon-sdk then all of the jpm tests mentioned above will be run on Travis-CI automatically and you will see the pass/fail results with a link to the log in the github pull request.  Only on a linux machine at the moment.

 

From Mozilla-Central repository

With a checkout of the mozilla-central source code, one can always cd addon-sdk/source and use any of the methods described above, but in addtion to that there are a couple of mach commands available, and ofcourse there is the try server if you have access to that.

With Mach

There are two commands:

  • ./mach jetpack-addon <optional_addon_path>:  This runs the test add-ons mentioned for cfx testaddons and gulp test:addons with the older sdk/loader/cuddlefish used with cfx.
  • ./mach jetpack-package <optional_file_path>:  This runs the module unit tests mentioned for cfx testpkgs and gulp test:modules but in this case with the newer toolkit/loader used with jpm.

With Try Server

 

 

Revision Source

<h2 id="From_Add-on_SDK_repository">From Add-on SDK repository</h2>

<p>With a checkout of the <a href="https://github.com/mozilla/addon-sdk">mozilla/addon-sdk</a> repository (or a checkout of the m-c repo and cd into the <a href="https://github.com/mozilla/gecko-dev/tree/master/addon-sdk/source">addon-sdk/source</a> directory) there are many means to run the addon-sdk tests.</p>

<h3 id="With_CFX">With CFX</h3>

<p>CFX tests use the deprecated <code><a href="/en-US/Add-ons/SDK/Low-Level_APIs/loader_cuddlefish">sdk/loader/cuddlefish</a></code>, which is being replaced by <code>toolkit/loader</code>.</p>

<p>With <code>cfx</code> (which is part of the addon-sdk repo), we can run the first test suite which was produced for the Add-on SDK.  This includes:</p>

<ul>
 <li><code><a href="/en-US/Add-ons/SDK/Tools/cfx#cfx_testcfx">cfx testcfx</a></code>: a suite of python tests which test cfx itself (which is written in python).  This suite basically tests cfx xpi's ability to produce the xpi files that we expect it to.</li>
 <li><code><a href="/en-US/Add-ons/SDK/Tools/cfx#cfx_testex">cfx testex --filter &lt;addon_example_folder_name&gt;</a></code>: a suite of tests which run test code for some example add-ons.   This suite builds the example code, then runs these example add-on's test code.</li>
 <li><code><a href="/en-US/Add-ons/SDK/Tools/cfx#cfx_testaddons">cfx testaddons --filter &lt;addon_folder_name&gt;</a></code>: a suite of tests which run add-ons, which are themseleves tests.  This suite builds add-ons which are tests (ie: their main.js script's merely run tests and close firefox when their tests are done), and runs them as cfx run would.</li>
 <li><code><a href="en-US/Add-ons/SDK/Tools/cfx#cfx_testpkgs">cfx testpkgs --filter &lt;file_name&gt;:&lt;test_name&gt;</a></code>: a suite of tests which run sdk module unit tests.  This suite builds the entire addon-sdk repo as an add-on, like cfx xpi would, then runs the add-on like cfx test would.  The majority of the tests run here are module unit tests, but there are various other tests included here as well.</li>
</ul>

<p class="info">Note: You must remember to run <code>source bin/activate</code> in order to enable <code>cfx</code> first.</p>

<h3 id="With_JPM">With JPM</h3>

<p>JPM tests all use the new <code>toolkit/loader</code>.</p>

<p>Wtih jpm (which is not part of the add-on sdk repo, and must be installed separately) things more difficult without the <a href="https://gulpjs.com/">Gulp</a> commands provided by the <a href="https://github.com/mozilla/addon-sdk/blob/master/gulpfile.js">gulpscript.js</a> file in the addon-sdk repo.  With gulp installed, and after installing the addon-sdk's npm dependencies, we can run the latter three test suites mentioned for cfx with jpm using the following commands:</p>

<ul>
 <li><code>gulp test:examples --filter &lt;addon_example_folder_name&gt;</code></li>
 <li><code>gulp test:addons --filter &lt;addon_folder_name&gt;</code></li>
 <li><code>gulp test:modules --filter &lt;file_name&gt;:&lt;test_name&gt;</code></li>
</ul>

<p>or run all of the tests with <code>gulp test</code>.</p>

<h3 id="With_Travis">With Travis</h3>

<p>If you merely make a pull request for the <a href="https://github.com/mozilla/addon-sdk">mozilla/addon-sdk</a> then all of the <code>jpm</code> tests mentioned above will be run on <a href="https://travis-ci.org">Travis-CI</a> automatically and you will see the pass/fail results with a link to the log in the github pull request.  Only on a linux machine at the moment.</p>

<p> </p>

<h2 id="From_Mozilla-Central_repository">From Mozilla-Central repository</h2>

<p>With a checkout of the mozilla-central source code, one can always <code>cd addon-sdk/source</code> and use any of the methods described above, but in addtion to that there are a couple of <code><a href="/en-US/docs/Mozilla/Developer_guide/mach">mach</a></code> commands available, and ofcourse there is the try server if you have access to that.</p>

<h3 id="With_Mach">With Mach</h3>

<p>There are two commands:</p>

<ul>
 <li><code>./mach jetpack-addon &lt;optional_addon_path&gt;</code>:  This runs the test add-ons mentioned for <code>cfx testaddons</code> and <code>gulp test:addons</code> with the older <code>sdk/loader/cuddlefish</code> used with <code>cfx</code>.</li>
 <li><code>./mach jetpack-package &lt;optional_file_path&gt;</code>:  This runs the module unit tests mentioned for <code>cfx testpkgs</code> and <code>gulp test:modules</code> but in this case with the newer <code>toolkit/loader</code> used with <code>jpm</code>.</li>
</ul>

<h3 id="With_Try_Server">With Try Server</h3>

<p> </p>

<p> </p>
Revert to this revision