This document provides a steb by step guide on how to build the docker container, use Genymotion to emulate Android devices and use the container to run the test.
- Install Genymotion "personal use" and run an instance of Android
- Create a folder with the .apk
- Build the image using the Dockerfile (see below)
- Run the image and mount the folder with APK and tests (see below)
From the docker directory run
docker build -t "mobile_testing_automation:calabash_android" .
docker run -v /PATH/TO/YOUR/FOLDER/WITH/APK/AND/TESTS:/masvs_automation --privileged -i -t mobile_testing_automation:calabash_android /bin/bash
adb connect IP_OF_THE_EMULATOR_ON_THE_HOST
To get the IP of the emulator run adb devices -l
from the host machine.
Run calabash-android gen
to generate the feature folder
It will create a Cucumber skeleton in the current folder like this:
features
|_support
| |_app_installation_hooks.rb
| |_app_life_cycle_hooks.rb
| |_env.rb
| |_hooks.rb
|_step_definitions
| |_calabash_steps.rb
|_my_first.feature
where my_first.feature
will contain the gherkin syntax and calabash_steps.rb
will contain the Ruby code
calabash-android run APP.apk
On the host machine run
sysctl -w net.ipv4.tcp_mtu_probing=1net.ipv4.tcp_mtu_probing = 1
After setting up the container the keystore related issues ma raise. The following steps will help to fix the issue
- Navigate to /.android directory .
- Remove the existing debug.keystore file in case one exist
- Apply the command
$keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android -keyalg RSA -keysize 2048 -validity 10000
- Following that navigate to the directory where the feature files exist and setup the calabash android by using the command
$ calabash-android setup
- The resign the new debug.keystore file using the command
$ calabash-android resign <apk path>
- And finally run the test by using the command
$ calabash-android run <apk path>