30
Continous UI testing by with Espresso and Jenkins

Continous UI testing with Espresso and Jenkins

Embed Size (px)

Citation preview

Page 1: Continous UI testing with Espresso and Jenkins

Continous UI testingby

with Espresso and Jenkins

Page 3: Continous UI testing with Espresso and Jenkins

This is a story of my team's journey

Page 4: Continous UI testing with Espresso and Jenkins

...jurney to CI/CD

We are a small team

Page 5: Continous UI testing with Espresso and Jenkins

...jurney to CI/CD

We are a small team

- we are looking for things to be cost effective- not a perfect solution, but a decent one

Page 6: Continous UI testing with Espresso and Jenkins

What we have gained

- better, more agile work flow- no more Commit and run situations- way to check UI on many configurations- less regression bugs- higher code quality

Page 7: Continous UI testing with Espresso and Jenkins

We started with tests

- JVM tests (finally works in AS)- Robolectric- Instrumentation

Page 8: Continous UI testing with Espresso and Jenkins

We wanted more from VCS

- Use DVCS- Gitflow = git++- Branch per feature, tag per release

Page 9: Continous UI testing with Espresso and Jenkins

Static code analysis

- FindBugs- PMD- Checkstyle- SonarCube

Page 10: Continous UI testing with Espresso and Jenkins

Continous Integration checklist

- gitflow ✔- unit tests ✔- code coverage ✔- static analysis ✔- build with one command ✔

Page 11: Continous UI testing with Espresso and Jenkins

We needed our CI server

- Jenkins- Travis- Circle CI- TeamCity- Bamboo...

Page 12: Continous UI testing with Espresso and Jenkins

Why Jenkins?

- free of change, but not of hustle- great community- can be hosted on any device- hundreds of plugins

Page 13: Continous UI testing with Espresso and Jenkins

Where to host it?

- CloudBees.com- VPS: s3, digital ocean- bare metal

Page 14: Continous UI testing with Espresso and Jenkins

Perfect local Jenkins machine

- good price/performance (i5, ssd, ram)- energy effective- quiet- small

Candidates:- Intel NUC (7W idle)- Mac Mini

Page 15: Continous UI testing with Espresso and Jenkins

CI setup

Ubuntu- apt-get install- sdk install (Android Plugin don't install everything)- kvm- plugins (Chuck Norris, Lint Publisher, jacoco...)

Page 16: Continous UI testing with Espresso and Jenkins

First easy win

- create new project- add git with credentials

./gradlew build test jacoco

You get:- compilation check- lint check- unit tests with code coverage

Page 17: Continous UI testing with Espresso and Jenkins

We wanted more

Instrumentation tests- Robotium- Appium- Espresso- UI Automator

Page 18: Continous UI testing with Espresso and Jenkins

Some Espresso

Great way to test UI, and do integration testsApi from developers to developers

onView(Matcher).perform(ViewActions).check(ViewAssertions)

More on Maciej's speach at 12:00:„Expressive functional testing with Espresso”

Page 19: Continous UI testing with Espresso and Jenkins

How to test API?

Mock/stub API classes

- Dagger FTW- works great with Retrofit

Page 20: Continous UI testing with Espresso and Jenkins

How to test API?

MockWebServer

- set HTTP mock for one test- Square Quality™, build upon OkHttp- mock calls, verify where they called

Page 21: Continous UI testing with Espresso and Jenkins

How to test API?

AndroidStubServer

- HTTP server build in your APK (good for integration testing )- can be sent to client within app

simple config:{"method": "GET",

"path": "/books", "response file": "books.json"}

https://github.com/byoutline/AndroidStubServer

Page 22: Continous UI testing with Espresso and Jenkins

Where to run Instrumentation tests?

- androd emulators (x86 if possible)- genymotion- real devices

Page 23: Continous UI testing with Espresso and Jenkins

Start simple

- create job with single emu- use Android Emulator Plugin for configuration- start instrumentation tests in gradle

./gradlew connectedCheck

Page 24: Continous UI testing with Espresso and Jenkins

Enter the matrix

- create Multi-configuration project- exclude combinations

Page 25: Continous UI testing with Espresso and Jenkins

Need a Spoon for your Espresso?

- great tool from Square (duh !)- run instrumentation tests on multiple devices in parallel- external plugin to run with gradle

https://github.com/stanfy/spoon-gradle-plugin

- connect your devices to CI server with USB hub- generates nice looking reports

Page 26: Continous UI testing with Espresso and Jenkins

One step further - Continous Delivery

- your code is tested and ready to meet the world- create new job to deploy to distibution channel

CrashlyticsGoogle Play Alpha/Beta

- start after succesful build or manualy

Page 27: Continous UI testing with Espresso and Jenkins

When we need more devices

Devices in the cloud

- AppThwack - TestDroid...

Bonus:Some free Intel devices

Page 28: Continous UI testing with Espresso and Jenkins

How to make it even better?

Genymotion on server

http://www.slideshare.net/vishyrich/genymotion-with-jenkins

Page 29: Continous UI testing with Espresso and Jenkins

BDD with Calabash

Black box testing

calabash-android genwrite specification with Gherkin DSL Scenario: As a valid user I can log into my app When take picture When I press "Login" Then I see "Welcome to coolest app ever" Then take picture

calabash-android run APK

Works great with AndroidStubServer!