agomezmoron / docker-appium

Docker image to run your appium test against a defined Android emulador and SDK
MIT License
13 stars 6 forks source link

docker-appium

Docker image to run your appium test against a defined Android emulador and SDK

Based on vbanthia's idea but parametrized and based on Docker Ubuntu 14.04.

I really appreciate Pablo M. Sobrado's contributions because, without him, this project wouldn't exist.

Table of Contents

Prerequisites

This docker image is designed to run on Linux systems, may not work on Windows. You will need at least 25GB per build.

Build instructions

You can build your Docker image running the Dockerfile with the following command:

$ docker build -t agomezmoron/docker-appium . && docker rmi -f $(docker images -f "dangling=true" -q) &> /dev/null

or pulling it from docker:

$ docker pull agomezmoron/docker-appium

Optional arguments

You can specify the Java and Appium version, the Android SDK or the VNC password to use with the following variables (the values used are the default ones):

JAVA_VERSION=8
ANDROID_SDK_VERSION=23
VNC_PASSWD=1234
APPIUM_VERSION=1.5.2

Usage:

$ docker build --build-arg JAVA_VERSION=8 --build-arg ANDROID_SDK_VERSION=23 --build-arg VNC_PASSWD=1234 -t agomezmoron/docker-appium . && docker rmi -f $(docker images -f "dangling=true" -q) &> /dev/null

Possible inputs

Java:

Android SDK:

Notes

The second part of the command, '&& docker rmi -f $(docker images -f "dangling=true" -q) &> /dev/null', is an optional one that deletes past images of the builds so the PC does not end up with several duplicated images. It can be removed without affecting the build.

Run instructions

Run the image with the following command:

$ docker run --privileged -v /YOUR/SOURCES/FOLDER:/src -v /YOUR/TARGET/FOLDER:/src/target -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) -e DOCKER_TESTS_COMMAND="YOUR_MAVEN_COMMAND" --rm -t -i -p 5900:5900 agomezmoron/docker-appium

Mandatory arguments

Please note that you WILL have to specify your sources folder for appium to run, AS WELL as a target folder for when it ends. Also, you MUST input a maven command, for example:

mvn test -Pandroid,ci

Command specific arguments

Optional arguments

You can choose to update the SDK when running the image. This may be useful in some cases. Just specify it like this:

UPDATE="y"

The run command will create an Android emulator before launching it. You can specify its CPU and device with the following variables (the values used are the default ones):

DEVICE="Nexus S"
ABI="default/x86_64"

Usage:

$ docker run --privileged -v /YOUR/SOURCES/FOLDER:/src -v /YOUR/TARGET/FOLDER:/src/target -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) -e DOCKER_TESTS_COMMAND="YOUR_MAVEN_COMMAND" -e DEVICE="Nexus S" -e ABI="default/x86_64" -e UPDATE="y" --rm -t -i --net=host agomezmoron/docker-appium

Possible inputs

ABIs (CPUs):

Devices:

VNC connection

Open Remmina, a built-in app in Ubuntu. Configure a new connection like this:

Click on 'Connect' -or 'Save' if you want to store the connection for further uses- and you should be able to see the emulator, as long as the image is up and running.

Troubleshooting

Errors on the build or run step

You can try first stopping and removing the images:

$ docker stop $(docker ps -a -q) && docker rm -f $(docker ps -a -q)

then deleting them with docker rmi -f image_id. You can check the images ids by running:

$ docker images

Errors on the VNC connection

You can try first stopping and removing the images:

$ docker stop $(docker ps -a -q) && docker rm -f $(docker ps -a -q)

then running the image again and reconnecting. If the connection still fails, try restarting the docker daemon:

$ sudo service docker restart