Use Bitrise with Genymotion SaaS

April 23, 2024

Note This article is a reproduction of a medium article: Learn how to integrate Genymotion Cloud Android Virtual Devices into your workflows and use the testing framework of your choice on Bitrise. by Thomas Carpentier.

Connect your Android project to Bitrise Adding an application to Bitrise is really simple; please refer to the official documentation for details. After having connected your Android application to bitrise.io, a workflow is created with several default Android steps. The following screenshot shows the default workflow:

Build an Android application

In order to run Appium tests, you need to build your Android application. So let’s add the “Android build” step to your workflow. When this step is executed, the APK path is pushed to an environment variable ( $BITRISE_APK_PATH ) which we will use later when we run the tests.

Install and start an Appium server

We will use the “Script” step to install and start an Appium server.

As it is a Bash script, it allows you to start an Appium server with the needed capabilities, the arguments are described here.

Add Genymotion SaaS start instances step

This step starts one or several devices on the Genymotion SaaS platform

This step has several required parameters:

Run tests

In this tutorial, we use an Android application with Appium tests written in Python. Source code is public and available on Github. Even if you use another language, the logic is the same.

#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
#export JAVA_HOME
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
npm install -g appium --unsafe-perm=true --allow-root
appium &>/dev/null &
view raw
Start Appium server
hosted with
by
GitHub

#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
echo "# Install dependencies"
pip3 install -r appium/requirements.txt
# Execute tests through pytest
echo "# Execute tests"
pytest -n 2 appium/test_send_message.py --apk $BITRISE_APK_PATH

#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x
echo "# Install dependencies"
pip3 install -r appium/requirements.txt
# Execute tests through pytest
echo "# Execute tests"
pytest -n 2 appium/test_send_message.py --apk $BITRISE_APK_PATH

Start Appium server hosted with by GitHub ```

Add Genymotion SaaS stop instances step This step will stop all Genymotion SaaS instances started in the “start” step. This step will always run to make sure that no instances are left running in case a previous step fails the build. No need to change the input variable “Instance UUID”, it is automatically exported in the “start” step.

Conclusion At the end of this tutorial, you should be able to create a complete Continuous Integration workflow for your application, including unit and UI testing. You can improve your workflow by adding other steps in order to deliver your application, but this is another story You can find more information here. If you have any questions, feel free to submit a request from Genymotion SaaS platform. To find more information, do not hesitate to read our documentation.

Genymotion SaaS steps are open-source, so feel free to create an issue or contribute https://github.com/Genymobile/bitrise-step-genymotion-cloud-saas-start and https://github.com/Genymobile/bitrise-step-genymotion-cloud-saas-stop

The Android application code sample used in this tutorial is available on Github.

Last but not least, enjoy your Bitrise CI/CD workflow with Genymotion SaaS!