continous ui testing with espresso and jenkins
TRANSCRIPT
![Page 1: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/1.jpg)
Continous UI testingby
with Espresso and Jenkins
![Page 2: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/2.jpg)
Sylwester MadejFounder & Head Developer@smdremedy
#droidconZG
byoutline.com
2
![Page 3: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/3.jpg)
This is a story of my team's journey
![Page 4: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/4.jpg)
...jurney to CI/CD
We are a small team
![Page 5: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/5.jpg)
...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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/6.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/7.jpg)
We started with tests
- JVM tests (finally works in AS)- Robolectric- Instrumentation
![Page 8: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/8.jpg)
We wanted more from VCS
- Use DVCS- Gitflow = git++- Branch per feature, tag per release
![Page 9: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/9.jpg)
Static code analysis
- FindBugs- PMD- Checkstyle- SonarCube
![Page 10: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/10.jpg)
Continous Integration checklist
- gitflow ✔- unit tests ✔- code coverage ✔- static analysis ✔- build with one command ✔
![Page 11: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/11.jpg)
We needed our CI server
- Jenkins- Travis- Circle CI- TeamCity- Bamboo...
![Page 12: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/12.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/13.jpg)
Where to host it?
- CloudBees.com- VPS: s3, digital ocean- bare metal
![Page 14: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/14.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/15.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/16.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/17.jpg)
We wanted more
Instrumentation tests- Robotium- Appium- Espresso- UI Automator
![Page 18: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/18.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/19.jpg)
How to test API?
Mock/stub API classes
- Dagger FTW- works great with Retrofit
![Page 20: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/20.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/21.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/22.jpg)
Where to run Instrumentation tests?
- androd emulators (x86 if possible)- genymotion- real devices
![Page 23: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/23.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/24.jpg)
Enter the matrix
- create Multi-configuration project- exclude combinations
![Page 25: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/25.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/26.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/27.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/28.jpg)
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](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/29.jpg)
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!
![Page 30: Continous UI testing with Espresso and Jenkins](https://reader034.vdocument.in/reader034/viewer/2022042716/55b15869bb61eb80028b4685/html5/thumbnails/30.jpg)
Sylwester MadejFounder & Head Developer@smdremedy
byoutline.com
30