Genymotion Cloud offers automation features useful for automating tests and continuous integration, regardless of your test framework (Espresso, Robotium, Selenium, Appium) or continuous integration server (Jenkins, TeamCity, Travis or Bamboo). Those features are exposed through a development tools:
gmsaas. It is a command line tool specific to Genymotion that allows you to manage the lifecycle of your virtual devices and enable any ADB interactions between your environment and your instance.
This chapter details how to automate actions in Genymotion Cloud using
Automating actions with gmsaas
This section explains how to automate your instrumented tests from your desktop and run them locally or in using the command line tool
gmsaas for Genymotion Cloud. Please refer to gmsaas command line tool for
gmsaas installation and usage.
To run instrumented tests from your desktop, you must be authenticated on
Running instrumented tests
Create and start your instance by running:
gmsaas instances start <RECIPE_UUID> <INSTANCE_NAME>
<RECIPE_UUID>is the recipe identifier and
<INSTANCE_NAME>is the name you wish to give to the instance. Once up, the command returns and shows the
The list of available recipes can be retrieved using this command:
gmsaas recipes list.
Connect the instance to ADB
gmsaas instances adbconnect <INSTANCE_NAME> [--adb-serial-port <VALUE>]
Run your instrumented tests using:
- AndroidStudio in Gradle toolbox: Tasks > verification > connectedAndroidTest
You can view your tests running in the virtual device by signing in to Genymotion Cloud.
Once your tests have run, stop the virtual devices using:
gmsaas instances stop <INSTANCE_UUID>
<INSTANCE_UUID>is the UUID (not the name!) of the instance used for the test. All data generated on the virtual device during the tests are destroyed.
Running instrumented tests with Genymotion Java API
To run your instrumented tests, you can also use the Genymotion Java API in order to automate the modification of sensor values such as battery, GPS, ID, SMS, calls... For more information on the implementation of the Genymotion Java API, please refer to the official documentation. A sample project is available at https://github.com/Genymobile/genymotion-binocle.
Running instrumented tests from Jenkins
This section explains how to automate your instrumented tests from your Jenkins continuous integration server using the for Genymotion.
gmsaastool. Please refer to gmsaas command line tool for instructions.
Configuring a Jenkins job with gmsaas
To configure the Jenkins job that will run your instrumented test, from Jenkins, go to menu Configure.
In Source Code Management, enter the location of the application source code.
From the Build section:
Add Execute shell to run commands and add the following commands:
<GMSAAS_PATH>/gmsaas auth login <EMAIL> <PASSWORD>
<GMSAAS_PATH>is the location of gmsaas on your Jenkins,
<PASSWORD>are the email and password of your Genymotion Cloud account. This authenticates you to Genymotion.
<GMSAAS_PATH>/gmsaas instances start <RECIPE_UUID> <NAME>
<RECIPE_UUID>is the device recipe/template uuid (you can get all the recipes by using the command
gmsaas recipes list) and
<NAME>is the name you wish to give to the instance.
Please note that
<NAME>is only use as a tag. You should not use it to issue commands from
gmsaasto an instance. Use the instance UUID instead.
Please refer to section Automating actions with Gmsaas for details.
Add Invoke Gradle script to run your instrumented test.
Tick Root Build Script Dir.
To have more logs, in Switches, enter
In Tasks, add
From the Post Build section:
- Add Publish JUnit test result report & Publish HTML reports to get test reports.
- Add Execute a set of scripts to stop the device where the tests were run. In Build steps, add Execute shell section and add the following command:
<GMSAAS_PATH>/gmsaas instances stop <UUID>where
<UUID>is the UUID of the virtual device you created (not the
Running the builds
You can run the builds manually by clicking Build with Parameters or have it automatically built by configuring a scheduled build.
Viewing test reports
Once your tests have run, you can view your test reports from Test Report.