Run your mobile automated tests on Genymotion Cloud Android Virtual Devices with CircleCI

Ellinor Kwok
May 5, 2020 · 4 min read

Efficiently testing mobile apps at every stage of the application lifecycle is challenging, even more with Android fragmented market. Many companies are adopting tools to help them create, automate and orchestrate tests on mobile devices. Among them are continuous integration and deployment (CI/CD) tools. Having a CI tool isn’t enough, we also need devices to run tests on. By partnering with CircleCI, we help providing the full continuous integration workflow.

Genymotion Cloud SaaS provides Android virtual devices on the Cloud with various configurations and Android versions. CircleCI is a cloud continuous integration server to help teams get faster builds, shorter feedback lifecycles and simplified pipeline maintenance.

The integration of Genymotion Cloud SaaS is now available on CircleCI as an Orb, so QA engineers can now easily integrate Genymotion Cloud in their test cases on CircleCI and reuse jobs, commands and executors to run their test on chosen devices.

In this article, we are going to cover Espresso written tests but you can also use any other testing framework.

To run tests in parallel with CircleCI i.e running your tests on several devices at the same time, you also need to have a CircleCI plan that supports more than one job at a time.

1. Create your test workflow with config.yml file

Genymotion Cloud SaaS account credentials need to be set as environment variables :

  • GMCLOUD_SAAS_EMAIL : it is the email of your Genymotion Cloud SaaS account; if you don’t have an account, please create it first on https://cloud.geny.io.
  • GMCLOUD_SAAS_PASSWORD : it is the password for your Genymotion Cloud SaaS account.

We will cover two examples :
Start/Stop Genymotion Cloud devices with a single predefined job or with orb commands in your own job.

Start & Stop Genymotion Cloud devices

recipe_uuid : Recipe UUID is the identifier used when starting an instance, it can be retrieved using gmsaas recipes list command line. The comprehensive list of all currently available recipes UUIDs are available here

adb_serial_port : it is the port through which the instance will be connected to ADB, for example: localhost:adb_serial_port.

If you do not specify any ADB serial ports, it will be generated randomly

a/ Use the job defined with the orb

With this single job, authentication on Genymotion Cloud, start & stop devices steps are included in the genymotion-saas/run_testsstep. Only the recipe_uuid is required, adb_serial_port is optional.
It needs to be directly used in the workflow.

Running tests after a commit
All steps are done with genymotion-saas-orb job

b/ Use orb commands in your own job

To start a device (adb_serial_port is optional)

To stop a device after running the tests
- genymotion-saas/stop-instance

So a job that runs tests on an Android 9 devices will look like :

Run the tests

Scale your tests by running your tests in parallel

where android9, android10 are jobs with genymotion-saas/start-instance steps that start respectively an Android 9 & Android 10 devices.
To start these devices in parallel, you need to have subscribed to the CircleCI plan that enables more than one job to run in parallel.

Run tests in parallel

2. Get running on CircleCI

3. Conclusion

If you have any questions, feel free to contact us on our website, on Genymotion Cloud SaaS platform. To find more information, please visit our help center or read our documentation.

Genymotion Cloud SaaS orb is open-source, so feel free to create an issue or contribute.

The Android application code sample and the config.yml file used in this tutorial is available on Github

Enjoy running your automated tests on Genymotion Cloud SaaS from CircleCI !

Thanks for the CircleCI team (special thanks to Kyle Tryon) for all their help !

Genymobile

We help enterprises build their future with Android We’re…

Genymobile

We help enterprises build their future with Android We’re the team behind @Genymotion, the most complete Android emulation platform. Now available in the cloud with powerful testing and collaboration capabilities 💪☁️ ️More at genymotion.com/cloud

Ellinor Kwok

Written by

Presales, Technical Partnership Manager at Genymobile

Genymobile

We help enterprises build their future with Android We’re the team behind @Genymotion, the most complete Android emulation platform. Now available in the cloud with powerful testing and collaboration capabilities 💪☁️ ️More at genymotion.com/cloud

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store