This article has been adapted from this media article: Create your test infrastructure with Genymotion Cloud SaaS and Terraform
Setup Genymotion SaaS (Cloud) and install prerequisites
- Create a Genymotion Cloud account here.
- Install Android SDK.
- Install gmsaas. It is our tool to manage Genymotion SaaS instances. It is a Python package, so you can download it using
pip3 install gmsaas.
- Configure the path to your Android SDK with:
gmsaas config set android-sdk-path <SDK-PATH>.
- Download Terraform from here.
- Read this guide on how to install Terraform depending your operating system
Build and Destroy your first instance using Terraform
Now we have created our Genymotion Cloud account, downloaded and configured gmsaas; let’s start our first Genymotion SaaS instances using Terraform.
Create a new file, called
In the provider block, we call the Genymotion provider plugin from Terraform. We set the credentials from the user we have created.
Then we use the resource identifier “genymotion_cloud” to state that we are trying to start a Genymotion SaaS (Cloud) instance followed by the name identifier. Here, we use Android90 because we will start an Android 9.0 instance.
Fill the recipe_uuid argument. A recipe is a template with a given Android version, display size, density and specifications (CPU, memory, storage) which generally matches those of a real device. You can get the list of all recipe UUID using
gmsaas recipes list. Select the recipe UUID that best fits your needs.
Fill the name argument. It is the name of the instance you want to create. It is just declarative!
Now, it is time to run
terraform init command. It will download and initialize the Genymotion provider plugin:
terraform plan command. It describes what Terraform does before applying:
Ready to create instances? Run
terraform apply command:
Let’s go to https://cloud.geny.io ; you can see that three instances have started:
Once you have finished your tests, it is time to stop thoses instances. So we will run
terraform destroy command in order to destroy the test infrastructure:
Note: a powerful Terraform feature is the ability to create/destroy resources in parallel. It gives you a faster creation/destruction cycle for your test infrastructure!
Now that you are able to create a test infrastructure on Genymotion SaaS (Cloud) with Terraform, you can run your Android Tests (Appium, Espresso or other test automation frameworks) with several devices, in parallel.
For more information about parallel testing, you can refer to Run parallel tests with Appium on Android using Genymotion SaaS (Cloud)
You can also find more information about the Genymotion providers on Terraform website: https://www.terraform.io/docs/providers/genymotion/index.html