Jetpack/Testing: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 50: Line 50:
You can then run the debugger using that command.
You can then run the debugger using that command.


Need more detail? Read the rest of this document to learn all about the SDK's test suites and harness!
== cfx test* ==
 
 
First, follow [https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/addon-development/installation.html these instructions] to download, install, and activate the SDK.


You can run tests using the <code>cfx</code> command-line tool. There's [https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/addon-development/cfx-tool.html cfx documentation here], and command line help is available by typing:
You can run tests using the <code>cfx</code> command-line tool. There's [https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/addon-development/cfx-tool.html cfx documentation here], and command line help is available by typing:
Line 67: Line 64:
   testall    - test whole environment
   testall    - test whole environment


== cfx test ==
=== cfx test ===


<code>cfx test</code> runs the tests implemented for a single SDK "package". A package is a collection of JavaScript modules, and is defined as such by the presence of a file called "package.json" in its root directory. Among other things, "package.json" includes an string called "tests" which describes where the package's test suites live. If this is not defined, the default is the "tests" or "test" directory under the package root.
<code>cfx test</code> runs the tests implemented for a single SDK "package". A package is a collection of JavaScript modules, and is defined as such by the presence of a file called "package.json" in its root directory. Among other things, "package.json" includes an string called "tests" which describes where the package's test suites live. If this is not defined, the default is the "tests" or "test" directory under the package root.
Line 79: Line 76:
An add-on is a package, and the SDK's APIs are currently collected into two packages called "addon-kit" and "api-utils" (you can see them under the top-level "packages" directory).
An add-on is a package, and the SDK's APIs are currently collected into two packages called "addon-kit" and "api-utils" (you can see them under the top-level "packages" directory).


=== Testing an Add-on ===
==== Testing an Add-on ====


From the SDK root, navigate to "examples/reading-data" and explore the "tests" directory:
From the SDK root, navigate to "examples/reading-data" and explore the "tests" directory:
Line 128: Line 125:
  Program terminated successfully.
  Program terminated successfully.


=== Testing an SDK Package ===
==== Testing an SDK Package ====


An SDK package like "addon-kit" or "api-utils" is a package too, so the procedure is the same. Executing <code>cfx test</code> from the root of "addon-kit" will execute all the following test suites:
An SDK package like "addon-kit" or "api-utils" is a package too, so the procedure is the same. Executing <code>cfx test</code> from the root of "addon-kit" will execute all the following test suites:
Line 175: Line 172:
  Program terminated successfully.
  Program terminated successfully.


== cfx testcfx ==
=== cfx testcfx ===


<code>cfx testcfx</code> tests the <code>cfx</code> tool itself. <code>cfx</code> is written in Python, and <code>testcfx</code> uses Python's <code>unittest</code> framework.
<code>cfx testcfx</code> tests the <code>cfx</code> tool itself. <code>cfx</code> is written in Python, and <code>testcfx</code> uses Python's <code>unittest</code> framework.
Line 203: Line 200:
It also looks for [http://docs.python.org/library/doctest.html DocTests] in the documentation files, and executes any that it finds. But there aren't any, at the moment.
It also looks for [http://docs.python.org/library/doctest.html DocTests] in the documentation files, and executes any that it finds. But there aren't any, at the moment.


== cfx testex ==
=== cfx testex ===


<code>cfx testcfx</code> runs <code>cfx test</code> for all the add-ons which ship with the SDK under the examples/ directory.
<code>cfx testcfx</code> runs <code>cfx test</code> for all the add-ons which ship with the SDK under the examples/ directory.


== cfx testpkgs ==
=== cfx testpkgs ===


<code>cfx testpkgs</code> finds all packages installed under the packages/ directory, and executes <code>cfx test</code> for each package it finds.
<code>cfx testpkgs</code> finds all packages installed under the packages/ directory, and executes <code>cfx test</code> for each package it finds.


== cfx testall ==
=== cfx testall ===


<code>cfx testall</code> tests everything:
<code>cfx testall</code> tests everything:
canmove, Confirmed users
737

edits

Navigation menu