Gaia Integration tests

  • Revision slug: Mozilla/Firefox_OS/Platform/Testing/Gaia_integration_tests
  • Revision title: Gaia Integration tests
  • Revision id: 442951
  • Created:
  • Creator: mdas
  • Is current revision? No
  • Comment updating marionette information

Revision Content

Warning: This document assumes you fully understand how to work within Gaia and B2G.

See Hacking Gaia to get started with Gaia.

This document covers running and writing integration tests for Gaia apps. It covers the information in the README.md.

Running tests

Pre-requisites

You need the gaia repository and B2G desktop.

(December 21st, 2012) Note: We're currently using the b2g18 nightly builds for B2G desktop which are located here: http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/latest-mozilla-b2g18/

Running all the tests

First, you need to generate a profile. If you specify NOFTU=1, then it'll generate a profile without the First Time User dialogs when it starts up. This reduces some of the pain of running integration tests for the first time with that profile:

NOFTU=1 make

Second, launch B2G Desktop.

Third, run the command line:

make test-integration

That will run all the integration tests for all the apps.

Options

You can run specific tests or groups of tests by specifying options.

To run tests for a specific app:

make test-integration APP=<APP>

To run tests for a specific file:

make test-integration TESTS=<PATH/TO/TESTFILE.js>

You can also optionally provide a reporter to use to format the test output. For example:

make test-integration REPORTER=List

Setting up your Gaia app

Although this guide should help make things easier, the best way to learn how to write, set up, and run tests is currently still to look at the source code; in particular, take a look at the calendar tests.

FIXME: Email app has tests coming, too.

Writing integration tests

The unit test runner is mocha using the TDD interface. Mocha doesn't ship with an assertion library (there is no ok or assert_equals), so we use chai to provide assertions.

It's highly recommended that you read though the mocha site, since all tests are really mocha tests. The documentation here is focused on getting you started, and about our special integrations with test-integration and Gaia.

It's also important to note that we add special functions (like require() and requireApp()) to make writing tests easier. Helper and scaffolding code can be found in the /tests directory.

File naming

Integration tests are located in the test/integration/ directory.

Revision Source

<div class="warning">
  <strong>Warning:</strong> This document assumes you fully understand how to work within Gaia and B2G.</div>
<p>See <a class="link-https" href="https://wiki.mozilla.org/Gaia/Hacking" title="https://wiki.mozilla.org/Gaia/Hacking">Hacking Gaia</a> to get started with Gaia.</p>
<p>This document covers running and writing integration tests for Gaia apps. It covers the information in the <a class="external" href="https://github.com/mozilla-b2g/gaia/blob/master/README.md" title="https://github.com/mozilla-b2g/gaia/blob/master/README.md">README.md</a>.</p>
<h2 id="Running_tests">Running tests</h2>
<h3 id="Pre-requisites">Pre-requisites</h3>
<p>You need the gaia repository and B2G desktop.</p>
<p><strong>(December 21st, 2012) Note:</strong> We're currently using the b2g18 nightly builds for B2G desktop which are located here: <a href="http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/latest-mozilla-b2g18/" title="http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/latest-mozilla-b2g18/">http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/latest-mozilla-b2g18/</a></p>
<h3 id="Running_all_the_tests">Running all the tests</h3>
<p>First, you need to generate a profile. If you specify <code>NOFTU=1</code>, then it'll generate a profile without the First Time User dialogs when it starts up. This reduces some of the pain of running integration tests for the first time with that profile:</p>
<pre>
NOFTU=1 make
</pre>
<p>Second, launch B2G Desktop.</p>
<p>Third, run the command line:</p>
<pre>
make test-integration
</pre>
<p>That will run all the integration tests for all the apps.</p>
<h3 id="Options">Options</h3>
<p>You can run specific tests or groups of tests by specifying options.</p>
<p>To run tests for a specific app:</p>
<pre>
make test-integration APP=&lt;APP&gt;
</pre>
<p>To run tests for a specific file:</p>
<pre>
make test-integration TESTS=&lt;PATH/TO/TESTFILE.js&gt;
</pre>
<p>You can also optionally provide a <a class="external" href="http://visionmedia.github.com/mocha/#reporters" title="http://visionmedia.github.com/mocha/#reporters">reporter</a> to use to format the test output. For example:</p>
<pre>
make test-integration REPORTER=List
</pre>
<h2 id="Setting_up_your_Gaia_app">Setting up your Gaia app</h2>
<p>Although this guide should help make things easier, the best way to learn how to write, set up, and run tests is currently still to look at the source code; in particular, take a look at the <a class="link-https" href="https://github.com/mozilla-b2g/gaia/tree/master/apps/calendar/test/integration" title="https://github.com/mozilla-b2g/gaia/tree/master/apps/calendar/test/integration">calendar tests</a>.</p>
<p>FIXME: Email app has tests coming, too.</p>
<h3 id="Writing_integration_tests">Writing integration tests</h3>
<p>The unit test runner is <a class="external" href="http://visionmedia.github.com/mocha/" title="http://visionmedia.github.com/mocha/">mocha</a> using the <a class="external" href="http://visionmedia.github.com/mocha/index.html#tdd-interface" title="http://visionmedia.github.com/mocha/index.html#tdd-interface">TDD interface</a>. Mocha doesn't ship with an assertion library (there is no <code>ok</code> or <code>assert_equals</code>), so we use <a class="external" href="http://chaijs.com/api/assert/" title="http://chaijs.com/code/assert.html">chai</a> to provide assertions.</p>
<p>It's highly recommended that you read though the <a class="external" href="http://visionmedia.github.com/mocha/" title="http://visionmedia.github.com/mocha/">mocha</a> site, since all tests are really mocha tests. The documentation here is focused on getting you started, and about our special integrations with test-integration and Gaia.</p>
<p>It's also important to note that we add special functions (like <code>require()</code> and <code>requireApp()</code>) to make writing tests easier. Helper and scaffolding code can be found in the <code><a class="link-https" href="https://github.com/mozilla-b2g/gaia/tree/master/tests" title="https://github.com/mozilla-b2g/gaia/tree/master/tests">/tests</a></code> directory.</p>
<h4 id="File_naming"><strong>File naming</strong></h4>
<p>Integration tests are located in the <code>test/integration/</code> directory.</p>
Revert to this revision