Continuous Integration of Mobile Apps with Docker and Appium

Post on 29-Jan-2018

441 views 2 download

Transcript of Continuous Integration of Mobile Apps with Docker and Appium

Continuous Integration of mobile

apps with Appium and Docker

@agomezmoron

#opensouthcode

2 of 66First of all, let’s take a selfie!

#opensouthcode @agomezmoron

3 of 66About me

agomezmoron-compose.yml

version: '1987'services:

works on:- company: { name: @emergya, role: QA & Team lead }- company: { name: @EPSUPO, role: QA teacher }

type: Non-stop learner

community: @SevillaQA organizer

#opensouthcode @agomezmoron

www.emergya.com

Roadmap

● Introduction

● What Appium is

● Appium architecture

● Type of apps to be tested

● Continuous Integration

● Docker as centerpiece

● Conclusions

#opensouthcode @agomezmoron

www.emergya.com

Introduction

#opensouthcode @agomezmoron

6 of 66Introduction

● Why do we develop for mobile devices?

● Why do we have to test apps?

#opensouthcode @agomezmoron

7 of 66Introduction

Why do we develop for mobile devices?

● Since 2014 there are more mobile users than desktop ones.

● People buy more mobile devices than non mobile ones.

source

#opensouthcode @agomezmoron

8 of 66

#opensouthcode @agomezmoron

Introduction

Why do we have to test apps?

● 90% of the time using apps vs 10% using the browser.

● Different OS (and also the same OS works different depending on

the version…).

● Native vs Hybrid apps.

source

www.emergya.com

What Appium is

#opensouthcode @agomezmoron

10 of 66What Appium is

● Appium is an open source test automation framework for use with

native, hybrid and mobile web apps.

● It drives iOS, Android, and Windows apps using the WebDriver

protocol.

#opensouthcode @agomezmoron

11 of 66What Appium is

Appium rules:

1. You shouldn’t have to recompile your app or modify it in any way in order

to automate it.

2. You shouldn’t be locked into a specific language or framework to write

and run your tests.

3. A mobile automation framework shouldn’t reinvent the wheel when it

comes to automation APIs.

4. A mobile automation framework should be open source, in spirit and

practice as well as in name!

#opensouthcode @agomezmoron

www.emergya.com

Appium architecture

#opensouthcode @agomezmoron

13 of 66Appium architecture

Appium test scriptJSON Wire protocol (WebDriver usage)

node.js

XCTest / UIAutomation (iOS)Selendroid (Android 2.3+)

UiAutomator (Android 4.2+)WinAppDriver (Windows)Marionette (Firefox OS)

#opensouthcode @agomezmoron

www.emergya.com

Types of apps to be tested

#opensouthcode @agomezmoron

15 of 66

#opensouthcode @agomezmoron

Type of apps to be tested

Device & Mobile API

Web

Mobile Browser Web

www.emergya.com

16 of 66

#opensouthcode @agomezmoron

Type of apps to be tested

Hybrid Apps

Device API

APP (WebView)HTML 5

17 of 66

#opensouthcode @agomezmoron

Type of apps to be tested

Native Apps

Device API

APP

18 of 66

#opensouthcode @agomezmoron

Type of apps to be tested

Native Apps

Device API

APP- Advanced touch actions

- Delays between commands

- etc

www.emergya.com

Continuous Integration

#opensouthcode @agomezmoron

20 of 66Continuous Integration

#opensouthcode @agomezmoron

21 of 66Continuous Integration

pull request

accept/reject

Developers’ code

Build the app

Testing

binary

#opensouthcode @agomezmoron

22 of 66Continuous Integration

Writing tests for mobile apps is easy but, what about running them?

● You can use cloud services (money!)

● You can use physical devices (money!)

● You can use emulators (memory usage!)

#opensouthcode @agomezmoron

www.emergya.com

Docker as centerpiece

#opensouthcode @agomezmoron

24 of 66

Appium test scriptJSON Wire protocol (WebDriver usage)

node.js

XCTest / UIAutomation (iOS)Selendroid (Android 2.3+)

UiAutomator (Android 4.2+)WinAppDriver (Windows)Marionette (Firefox OS)

Docker as centerpiece

#opensouthcode @agomezmoron

25 of 66

Appium test scriptJSON Wire protocol (WebDriver usage)

node.js

XCTest / UIAutomation (iOS)Selendroid (Android 2.3+)

UiAutomator (Android 4.2+)WinAppDriver (Windows)Marionette (Firefox OS)

X11

Docker as centerpiece

#opensouthcode @agomezmoron

26 of 66Docker as centerpiece

#opensouthcode @agomezmoron

$ 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

27 of 66Docker as centerpiece

#opensouthcode @agomezmoron

$ docker run --privileged -v /YOUR/SOURCES/FOLDER:/src -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) -e DOCKER_TESTS_COMMAND="DOCKER COMMAND TO BE RUN" --rm -t -i -p 5900:5900 agomezmoron/docker-appium

28 of 66Docker as centerpiece

#opensouthcode @agomezmoron

$ docker run --privileged -v /YOUR/SOURCES/FOLDER:/src -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) -e DOCKER_TESTS_COMMAND="DOCKER COMMAND TO BE RUN" --rm -t -i -p 5900:5900 agomezmoron/docker-appium

X11

/src

entrypoint

Test code

29 of 66

● It rocks but...you can only emulate once! So, you will have your

Jenkins node blocked (or you will need more slaves).

● So, it isn’t so easy...

Docker as centerpiece

#opensouthcode @agomezmoron

30 of 66Docker as centerpiece

#opensouthcode @agomezmoron

31 of 66

pull request

accept/reject

Developers’ code

Build the app

Testing

binary

Testing+ ZRAM +

Docker as centerpiece

#opensouthcode @agomezmoron

32 of 66

pull request

accept/reject

Developers’ code

Build the app

Testing

binary

Testing+ ZRAM +

Docker as centerpiece

#opensouthcode @agomezmoron

33 of 66

● Raspberry Pi 3 + ZRAM module will allow us to run our Docker

image with the emulator (emulators with ARM architecture).

● So the Raspberries are our Jenkins slaves!

Docker as centerpiece

#opensouthcode @agomezmoron

www.emergya.com

Conclusions

#opensouthcode @agomezmoron

35 of 66

● Appium is a framework that allows us to write tests for native & hybrid

mobile apps.

● Writing tests in Appium is not as easy as Selenium for Web Apps but

there are Open Source libraries to help us!

(https://github.com/agomezmoron/appium-handler)

Conclusions

#opensouthcode @agomezmoron

36 of 66

#opensouthcode @agomezmoron

● Appium is a framework that allows us to write tests for native & hybrid

mobile apps.

● Writing tests in Appium is not as easy as Selenium for Web Apps but

there are Open Source libraries to help us!

(https://github.com/agomezmoron/appium-handler)

Conclusions

37 of 66

#opensouthcode @agomezmoron

● Appium is a framework that allows us to write tests for native & hybrid

mobile apps.

● Writing tests in Appium is not as easy as Selenium for Web Apps but

there are Open Source libraries to help us!

(https://github.com/agomezmoron/appium-handler)

Conclusions

38 of 66

● There are some Dockers with Appium on the Internet but I use my own

image that contains Appium + Java + Android SDK (you can also

clone and build it customizing the versions).

(https://github.com/agomezmoron/docker-appium)

Conclusions

#opensouthcode @agomezmoron

www.emergya.com

Questions?

#opensouthcode @agomezmoron

www.emergya.com

Thanks!

#opensouthcode @agomezmoron