Gaia UI Tests Run Tests


Running Tests

    Basically, we can run gaia-ui-tests on a device with marionette server, emulators, and desktop B2G. However, please notice again that you should choose the right branch of gaia-ui-tests describing your B2G the best as we talked on previous section.

Testing on Devices

    First of all, connect your device through USB to computer, and then forward the package from the phone to computer port:

adb forward tcp:2828 tcp:2828

    You might get weird error, such as "no permission", from the command above. In that case, you could try to do the commands below:

adb kill-server
sudo adb devices
adb forward tcp:2828 tcp:2828

    It's almost all done before you start to run your tests! Before you start to run the test, read through this warning in order to start gaia-ui-tests correctly.
    Now, you can send this command to execute all gaiatests:

gaiatest <gaia_ui_tests folder>/tests/ --address=localhost:2828 --type=b2g-xfail <your manifest file location>

    Or, if you want to run solely one file, just do:

gaiatest <file> --address=localhost:2828 --type=b2g-xfail <your manifest file location>

    After the test, you will see all the result on pass/fail. And, for each individual test, it might have more information that you can go through. Here are some common examples you might be able to see:

Error Message Corresponding Actions
error: [Errno 111] Connection refused reissue adb forward command
Element ... not visible before timeout make sure the element would display on the app you test
TimeoutException: Condition timed out make sure the condition on the app is the same as your expectations
broken pip mostly bad marionette server issue


Testing on Emulator

Automatically launched emulator


Mannually launched emulator


Testing on Desktop B2G

    After you downloaded the Gaia UI test from GitHub, you also can use desktop build to run the tests. The Firefox OS desktop client, also called the B2G desktop client,  lets you run Gaia and Web apps in a Gecko-based environment somewhat  similar to an actual device. It doesn't emulate device hardware, so it's  not adequate for testing device APIs, and isn't a replacement for  testing on actual hardware. However, it does have a several APIs enabled  that aren't available on Firefox such as the Contacts and Settings  APIs. It can therefore be useful during the development of your  application, or while working on the Gaia user interface itself.

    You can download the latest build of the desktop client from this location, but make sure you download the appropriate file for your operating system.

  • Mac: b2g-[VERSION].multi.mac64.dmg
  • Linux (32bit): b2g-[VERSION].multi.linux-i686.tar.bz2
  • Linux (64bit): b2g-[VERSION].multi.linux-x86_64.tar.bz2

Note 1: Unfortunately, due to Bug 832469 the nightly desktop builds do not currently work on Windows, so you will need either Mac or Linux to continue :

Note 2: If you do not have the required operating systems installed on your machine, a virtual machine is fine as well.

    Once downloaded, you will need to extract the contents to a local folder. For the purposes of the rest of this guide, I’ll refer to this location as $B2G_HOME.
Add the following line to your gaia/profile/user.js file,

user_pref('marionette.force-local', true)

which on :

  • Mac is located in $B2G_HOME/
  • Linux is located in $B2G_HOME/b2g

    Because we’re running against the desktop client we must filter out all tests that are unsuitable. To run the tests, use the following command:

gaiatest --address=localhost:2828 --type=b2g-antenna-bluetooth-carrier-camera-sdcard-wifi-xfail <your manifest file location>

Test Variables

    There is one warning previously mentioned here. Please do read the warning before you setup your json test variables file.

    We use the --testvars option to pass in local variables, particularly those that cannot be checked into the repository. For example in gaia-ui-tests these variables can be your private login credentials, phone number or details of your WiFi connection.

    To use it, copy testvars_template.json to a different filename but add it into .gitignore so you don't check it into your repository.

    When running your tests add the argument: --testvars=(filename).json


this_phone_number (string) The phone number of the SIM card in your device. Prefix the number with '+' and your international dialing code.

remote_phone_number (string) A phone number that your device can call during the tests (try not to be a nuisance!). Prefix the number with '+' and your international dialing code.

wifi.ssid (string) This is the SSID/name of your WiFi connection. Currently this supports WPA/WEP/etc. You can add WiFi networks by doing the following (remember to replace "KeyManagement" and "wep" with the value your network supports) :

"wifi": { "ssid": "MyNetwork", "keyManagement": "WEP", "wep": "MyPassword" }

WPA-PSK: "wifi": { "ssid": "MyNetwork", "keyManagement": "WPA-PSK", "psk": "MyPassword" }

Marketplace: "marketplace": { "username": "MyUsername", "password": "MyPassword" }

Due to Bug 775499, WiFi connections via WPA-EAP are not capable at this time.


Test Parameters

    As you see in the last command we gave out on previous sections, there are many test variables for you to know. You can do this to get more information:

gaiatest --help


Test Data Prerequisites

Occasionally a test will need data on the hardware that cannot be set during the test setUp. The following tests need data set up before they can be run successfully:

test_ftu Requires a single record/contact saved onto the SIM card to test the SIM contact import


Go to "Writing Tests" section