MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla

Revision 390721 of Gaia UI Tests: Writing Tests

  • Revision slug: Mozilla/Firefox_OS/Platform/Testing/gaia-ui-tests/Gaia_UI_Tests_Write_Tests
  • Revision title: Gaia UI Tests Write Tests
  • Revision id: 390721
  • Created:
  • Creator: ypwalter
  • Is current revision? No
  • Comment
Tags: 

Revision Content

This page hasn't finished yet.
Your feedback to gaia-ui-automation@mozilla.org would be greatly appreciated.

Writing Tests

Tests Guidelines

    Your contribution is a big step to us! You may reference this page. I will brief out something here since that page is having some similiar topics as this MDN document.

    You can find related programming guide for marionette. This shows the basic layout and how you would write a test on gaia-ui-tests. Also, you will find we strictly go accord to PEP8 style except the 80 characters, E501. But, we do want to keep it within 100 charaters or so. If you are using Ubuntu, you can install a basic check program for PEP8 by doing:

sudo apt-get install pep8

    and, then you can check your program style by doing this command:

pep8 --ignore=E501 <your test file location and name>

    After you finished writing the test(s), you can then send a pull request from your branch to the branch in Mozilla that you want to contribute to! We also sometime open issues in github of Mozilla gaia-ui-tests to dicuss in advance. In that case, we can understand if our contribution was finished, if there are better suggestion, and if this contribution worth a million!

Test Examples

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from gaiatest import GaiaTestCase

class TestTemplate(GaiaTestCase):

    def setUp(self):
        # you should do something here to set up the environment
        GaiaTestCase.setUp(self)

    def test_template_1(self):
        # your first test regarding for this category of test
        ''' (description of where this test case is from, you may put a MozTrap link here)'''

    def test_template_2(self):
        # your second test regarding for this category of test
        ''' (description of where this test case is from, you may put a MozTrap link here)'''

    def tearDown(self):
        # you should do something here to clean the environment
        GaiaTestCase.tearDown(self)

Functions Reference

    At this point of time, we change codes dramatically everyday. We will try to come out a real gaia-ui-test mthods overview soon. But, before that comes into reality, you may take marionette methods page for reference. Furthermore, please do notice that marionette methods page has some out-of-date stuffs, too. Please kindly help us to correct them if possible.

    Another few good reference is to dig into the code to know the common libraries we are using in gaia UI tests. I suggests that you can start with gaia_test.py. Moreover, you can look into gaia_data_layer.js and gaia_apps.js

 

Debugging

 

CSS and XPath Locators

 

Test Types

Revision Source

<div class="warning">
  <p><em><strong>This page hasn't finished yet.<br />
    Your feedback to gaia-ui-automation@mozilla.org would be greatly appreciated.</strong></em></p>
</div>
<h2 id="Writing_Tests">Writing Tests</h2>
<h3 id="Tests_Guidelines">Tests Guidelines</h3>
<p>&nbsp;&nbsp;&nbsp; Your contribution is a big step to us! You may reference <a href="https://github.com/mozilla/gaia-ui-tests/blob/master/CONTRIBUTING.md" title="https://github.com/mozilla/gaia-ui-tests/blob/master/CONTRIBUTING.md">this page</a>. I will brief out something here since that page is having some similiar topics as this MDN document.<br />
  <br />
  &nbsp; &nbsp; You can find related <a href="https://developer.mozilla.org/en-US/docs/Marionette/Marionette_Python_Tests" title="https://developer.mozilla.org/en-US/docs/Marionette/Marionette_Python_Tests">programming guide for marionette</a>. This shows the basic layout and how you would write a test on gaia-ui-tests. Also, you will find we strictly go accord to <a href="http://www.python.org/dev/peps/pep-0008/" title="http://www.python.org/dev/peps/pep-0008/">PEP8</a> style except the 80 characters, E501. But, we do want to keep it within 100 charaters or so. If you are using Ubuntu, you can install a basic check program for PEP8 by doing:</p>
<pre>
sudo apt-get install pep8
</pre>
<p>&nbsp;&nbsp;&nbsp; and, then you can check your program style by doing this command:</p>
<pre>
pep8 --ignore=E501 &lt;your test file location and name&gt;</pre>
<p>&nbsp;&nbsp;&nbsp; After you finished writing the test(s), you can then send a pull request from your branch to the branch in Mozilla that you want to contribute to! We also sometime open issues in github of <a href="https://github.com/mozilla/gaia-ui-tests/issues?state=open" title="https://github.com/mozilla/gaia-ui-tests/issues?state=open">Mozilla gaia-ui-tests</a> to dicuss in advance. In that case, we can understand if our contribution was finished, if there are better suggestion, and if this contribution worth a million!</p>
<h3 id="Test_Examples">Test Examples</h3>
<pre class="brush: python">
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from gaiatest import GaiaTestCase

class TestTemplate(GaiaTestCase):

&nbsp;&nbsp;&nbsp; def setUp(self):
        # you should do something here to set up the environment
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GaiaTestCase.setUp(self)

&nbsp;&nbsp;&nbsp; def test_template_1(self):
        # your first test regarding for this category of test
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ''' (description of where this test case is from, you may put a MozTrap link here)'''

&nbsp;&nbsp;&nbsp; def test_template_2(self):
        # your second test regarding for this category of test
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ''' (description of where this test case is from, you may put a MozTrap link here)'''

&nbsp;&nbsp;&nbsp; def tearDown(self):
        # you should do something here to clean the environment
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GaiaTestCase.tearDown(self)

</pre>
<h3 id="Functions_Reference">Functions Reference</h3>
<p>&nbsp;&nbsp;&nbsp; At this point of time, we change codes dramatically everyday. We will try to come out a real gaia-ui-test mthods overview soon. But, before that comes into reality, you may take <a href="https://developer.mozilla.org/en-US/docs/Marionette/Marionette" title="https://developer.mozilla.org/en-US/docs/Marionette/Marionette">marionette methods page</a> for reference. Furthermore, please do notice that marionette methods page has some out-of-date stuffs, too. Please kindly help us to correct them if possible.<br />
  <br />
  &nbsp;&nbsp;&nbsp; Another few good reference is to dig into the code to know the common libraries we are using in gaia UI tests. I suggests that you can start with <strong>gaia_test.py</strong>. Moreover, you can look into gaia_data_layer.js and gaia_apps.js</p>
<p>&nbsp;</p>
<h3 id="Debugging">Debugging</h3>
<p>&nbsp;</p>
<h3 id="CSS_and_XPath_Locators">CSS and XPath Locators</h3>
<p style="text-align: center;">&nbsp;</p>
<h2 id="Test_Types">Test Types</h2>
Revert to this revision