Genymotion Desktop 3.7.1 is out!

Parallel tests with Appium and Genymotion SaaS

Appium and Genymotion SaaS animated gif.

Note

This article is a reproduction of How to run parallel tests with Appium on Android using Genymotion Cloud (SaaS) by Thomas Carpentier.

Launching automated tests can take a long time, so with this tutorial, you will learn how to parallelize your tests in order to detect bugs as soon as possible and spend less time on your test runs.

Requirements

We’re using Python throughout this tutorial but you can use your preferred language – simply refer to the Appium documentation for Appium clients for other languages.

Launch several devices in Genymotion SaaS

gmsaas recipes list lists recipes that can be started. UUID is the identifier used when starting an instance.

This step will create and launch several Genymotion devices:

# start a Google Nexus 5X - 8.0 device
instance1=$(gmsaas instances start bf1a9765-c743-4cdc-95ec-c40a74493055 device_8.0)

# start a Google Nexus 6P - 7.1 device
instance2=$(gmsaas instances start 00cd578a-14de-4f47-b4f1-d454d613d9da device_7.1)

# start a Google Nexus 6 - 7.0 device
instance3=$(gmsaas instances start a0a9c90a-b391-42f4-b77b-ae0561d74bbe device_7.0)

The instance UUID is printed on standard output once an instance is started.

Note

The following commands only work on Unix shell like Bash or Zsh, if you are on Windows, consider using bash.exe and call gmsaas.exe instead of gmsaas.

Once the devices are started, you need to connect them to adb:

port1=44 && port2=20000 && port3=30000

gmsaas instances adbconnect $instance1 --adb-serial-port=$port1
gmsaas instances adbconnect $instance2 --adb-serial-port=$port2
gmsaas instances adbconnect $instance3 --adb-serial-port=$port3

Keep the port numbers handy, as you will need them to configure the Appium server.

If you need a persistent adb port, you can add the parameter --adb-serial port (optional)

Start appium server

Since Appium 1.7, it’s easy to do parallel testing using only one appium server. Before that, we had to start N appium servers in order to test N devices in parallel.

So let’s start an Appium server, simply using the basic command: appium

Write your tests in Python

(Again, we’re using Python throughout this tutorial but you can use your preferred language.)

We’ve chosen to use Pytest as our test framework. It has several useful plugins like:

  • xdist: for running tests in parallel.
  • rerunfailures: for rerunning failed tests an arbitrary number of times to reduce build failures due to flakey tests.

Here is a simple python script:

How to run Python tests in parallel

Now, it’s time to run tests on all devices!

If we run the python script as follows:

pytest test_example.py

pytest will execute tests on one device at a time. This is not what we want. In order to have results as soon as possible, we need to execute all the tests at the same time. To do that, we can take advantage of the pytest-xdist plugin and run the following command:

pytest -n 3 test_example.py
  • -n : number of worker processes you want to use. Here we start the suite with 3 processes.

That’s it! You’ve been able to run parallel tests on several Genymotion SaaS virtual devices using appium and pytest.

Many thanks to Jonathan Lipps, one of the Appium maintainers and founder of Cloud Grey, for reviewing the article!

To learn more about Genymotion SaaS see the following resources: SaaS user guide

To run parallelize your tests using Java rather than Python, see Ellinor Kwok’s project on Github.

Select Product Portal

SaaS Platform

Access to our SaaS solution and use virtual machines in the cloud on any web browsers.

Or

Or

Desktop Platform

Access to manage your Genymotion Desktop licenses, your invoices and account information.

Select a Cloud provider Marketplace

How to get a quote for multiple Business Licenses?

  1. You need a Genymotion Desktop account. If you haven’t one yet, you can create it here.
  2. After creation and activation, or if you already have an account, follow this link.
  3. Add the number of desired licenses to your shopping cart and click “Continue to Billing”
  4. Add a shipping address, or select one if you already created one.
  5.  In the next page, click “Get a quote”:
    Payment details
  6. A quote will be automatically generated in PDF format.

Genymotion Device Image for Cloud providers
- Private Offer -

Genymotion Device On-premise
- Contact Us -

Genymotion SaaS
- Increase Maximum Simultaneous devices -

Genymotion SaaS Annual Plan
- Get a Quote -

Genymotion SaaS Premium Plan
- Get a Quote -

Personal Use - Free

Genymotion Desktop for personal use is not suitable for trial or POC: you will not get any assistance and some features will be disabled. If you have already selected “personal use” and wish to get a trial license, please contact our Sales at [email protected].

Technical support is not available with Genymotion Desktop free edition for personal use. For more details, please refer to Genymotion conditions of use (Personal Use).

The following features are not available in personal use mode:

Follow these steps to get Genymotion Desktop and activate personal use mode:

  1. Go to the Download page and get the latest version for your system.
  2. Follow the instructions from Genymotion Desktop quickstart guide to install Genymotion Desktop.
  3. Launch Genymotion and click CREATE to create an account. You should receive an activation email within an hour. If not, make sure to check your spam.
  4. After activating your account, return to Genymotion and log in with your credentials.
  5. Select personal use when prompted.
  6. Read Genymotion Desktop quickstart guide carefully to setup Genymotion for your needs.

Individual Offer Order

This offer is strictly reserved for personal use or individual workers (freelancers).

Educational Offer Order

The Educational subscription is restricted to:

  • schools, teachers or students who wish to use Genymotion Desktop for tuition
  • students who wish to use Genymotion Desktop for a school project

It is subject to valid proof (student card, teacher card, etc.)