Continuous Integration of Mobile Apps with Docker and Appium

40
Continuous Integration of mobile apps with Appium and Docker @agomezmoron #opensouthcode

Transcript of Continuous Integration of Mobile Apps with Docker and Appium

Page 1: Continuous Integration of Mobile Apps with Docker and Appium

Continuous Integration of mobile

apps with Appium and Docker

@agomezmoron

#opensouthcode

Page 2: Continuous Integration of Mobile Apps with Docker and Appium

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

#opensouthcode @agomezmoron

Page 3: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 4: Continuous Integration of Mobile Apps with Docker and Appium

www.emergya.com

Roadmap

● Introduction

● What Appium is

● Appium architecture

● Type of apps to be tested

● Continuous Integration

● Docker as centerpiece

● Conclusions

#opensouthcode @agomezmoron

Page 5: Continuous Integration of Mobile Apps with Docker and Appium

www.emergya.com

Introduction

#opensouthcode @agomezmoron

Page 6: Continuous Integration of Mobile Apps with Docker and Appium

6 of 66Introduction

● Why do we develop for mobile devices?

● Why do we have to test apps?

#opensouthcode @agomezmoron

Page 7: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 8: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 9: Continuous Integration of Mobile Apps with Docker and Appium

www.emergya.com

What Appium is

#opensouthcode @agomezmoron

Page 10: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 11: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 12: Continuous Integration of Mobile Apps with Docker and Appium

www.emergya.com

Appium architecture

#opensouthcode @agomezmoron

Page 13: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 14: Continuous Integration of Mobile Apps with Docker and Appium

www.emergya.com

Types of apps to be tested

#opensouthcode @agomezmoron

Page 15: Continuous Integration of Mobile Apps with Docker and Appium

15 of 66

#opensouthcode @agomezmoron

Type of apps to be tested

Device & Mobile API

Web

Mobile Browser Web

www.emergya.com

Page 16: Continuous Integration of Mobile Apps with Docker and Appium

16 of 66

#opensouthcode @agomezmoron

Type of apps to be tested

Hybrid Apps

Device API

APP (WebView)HTML 5

Page 17: Continuous Integration of Mobile Apps with Docker and Appium

17 of 66

#opensouthcode @agomezmoron

Type of apps to be tested

Native Apps

Device API

APP

Page 18: Continuous Integration of Mobile Apps with Docker and Appium

18 of 66

#opensouthcode @agomezmoron

Type of apps to be tested

Native Apps

Device API

APP- Advanced touch actions

- Delays between commands

- etc

Page 19: Continuous Integration of Mobile Apps with Docker and Appium

www.emergya.com

Continuous Integration

#opensouthcode @agomezmoron

Page 20: Continuous Integration of Mobile Apps with Docker and Appium

20 of 66Continuous Integration

#opensouthcode @agomezmoron

Page 21: Continuous Integration of Mobile Apps with Docker and Appium

21 of 66Continuous Integration

pull request

accept/reject

Developers’ code

Build the app

Testing

binary

#opensouthcode @agomezmoron

Page 22: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 23: Continuous Integration of Mobile Apps with Docker and Appium

www.emergya.com

Docker as centerpiece

#opensouthcode @agomezmoron

Page 24: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 25: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 26: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 27: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 28: Continuous Integration of Mobile Apps with Docker and 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

Page 29: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 30: Continuous Integration of Mobile Apps with Docker and Appium

30 of 66Docker as centerpiece

#opensouthcode @agomezmoron

Page 31: Continuous Integration of Mobile Apps with Docker and Appium

31 of 66

pull request

accept/reject

Developers’ code

Build the app

Testing

binary

Testing+ ZRAM +

Docker as centerpiece

#opensouthcode @agomezmoron

Page 32: Continuous Integration of Mobile Apps with Docker and Appium

32 of 66

pull request

accept/reject

Developers’ code

Build the app

Testing

binary

Testing+ ZRAM +

Docker as centerpiece

#opensouthcode @agomezmoron

Page 33: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 34: Continuous Integration of Mobile Apps with Docker and Appium

www.emergya.com

Conclusions

#opensouthcode @agomezmoron

Page 35: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 36: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 37: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 38: Continuous Integration of Mobile Apps with Docker and Appium

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

Page 39: Continuous Integration of Mobile Apps with Docker and Appium

www.emergya.com

Questions?

#opensouthcode @agomezmoron

Page 40: Continuous Integration of Mobile Apps with Docker and Appium

www.emergya.com

Thanks!

#opensouthcode @agomezmoron