This tutorial explains how to automate your instrumented tests from your Jenkins continuous integration server with Genymotion SaaS, using gmsaas command line tool.
Prerequisite
- adb from Android SDK platform-tools
- A Genymotion SaaS HTTP API Token
- gmsaas command line tool
Configuring a Jenkins job with gmsaas
To configure the Jenkins job that will run your instrumented test, from Jenkins, go to menu Configure.
1. In Source Code Management
Enter the location of the application source code:
2. In the Build section:
Note
<GMSAAS_PATH>
is the location of gmsaas on your Jenkins,<API_TOKEN>
is your Genymotion SaaS API Token. This authenticates you to Genymotion SaaS.<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.<NAME>
is only used as a tag – you should not use it to issue commands from gmsaas to an instance. Use the instance UUID instead.
Add Execute shell to run commands and add the following commands:
<GMSAAS_PATH>/gmsaas auth token <API_TOKEN>
<GMSAAS_PATH>/gmsaas instances start <RECIPE_UUID> <NAME>
<GMSAAS_PATH>/gmsaas instances adbconnect <NAME> [--adb-serial-port <VALUE>]
Add Invoke Gradle script to run your instrumented test.
Tick Root Build Script Dir. To have more logs, in Switches, enter --debug --stacktrace
In Tasks, add connectedAndroidTest
(cAT):
3. In 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 <NAME>
!).
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.