Mozilla's getting a new look. What do you think? https://mzl.la/brandsurvey

Part 7: Writing your own tests

So far we've given you most of the tools and information you need to start writing your own automated tests on Firefox OS, along with enough steps to follow to get you up and running quickly. In this part we are going to go pretty hands off, providing you with some resources and ideas, and then encouraging you to make your own way. Here we will start moving you towards writing your own tests — enjoy!

Resources

The following resources will be useful as you start to build your own unit tests.

  • The Firefox OS App Manager is a great tool for debugging Gaia directly on a device, or in a simulator. This is a good way to inspect the underlying code to find out what locators to use for accessing and manipulating elements.
  • As a more limited but lower overhead inspection mechanism, you can also dump the HTML source to the console using the print self.marionette.page_source command.
  • Another option is to look at the raw HTML in the Gaia Git repo.
  • To learn more about Marionette commands, read the Marionette docs.

Ideas for new and modified tests

This section provides a few ideas to get you started.

Modifying test_add_contact.py

Let's start by modifying the test we've already worked on:

  1. Make the test contact have a unique name every time.
  2. Delete all of the contacts in the setUp() step.
  3. Wake the screen before unlocking.

Now let's add another test method. This can be called anything you like as long as it has test_ at the start of the name. This test should do the following:

  1. Open Contacts.
  2. Create a contact with a different name to the one created by the first test.
  3. Re-enter the contact in edit mode.
  4. Add a Company.
  5. Tap Done.
  6. Assert that the company is listed.

Now when you execute the test file, both tests will run. Now we’re getting closer to the strength of test automation — the ability to run a series of tests automatically and report the results!

Some new test ideas

  • Create a contact, edit the contact and change the name. The name change should be reflected on the screen.
  • Create a contact and 'star' it to add it as a favourite. On the main screen it should be listed under the * (starred) category.
  • Create a contact with a phone number. After opening the contact's record and tapping on the "Message" icon, the Messages app should open with the contact in the recipient field.

 

Document Tags and Contributors

 Contributors to this page: chrisdavidmills, terrameijar, HossainAlIkram, Tingyu, zac_c
 Last updated by: chrisdavidmills,