using espresso for fast and reliable feedback

36
Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile Using Espresso for Fast and Reliable Feedback Embedding quality across the Android lifecycle Web: perfectomobile.com Twitter: @perfectomobile

Upload: perfecto-mobile

Post on 05-Apr-2017

287 views

Category:

Mobile


3 download

TRANSCRIPT

Page 1: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Using Espresso for Fast and Reliable Feedback

Embedding quality across the Android lifecycle

Web: perfectomobile.com Twitter: @perfectomobile

Page 2: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

● Session is being recorded

● Email once presentation is posted

● Questions and conversation○ Twitter: #justletmecode○ WebEx chat panel○ Q&A at the end of the webinar

Housekeeping

Page 3: Using Espresso for Fast and Reliable Feedback

Paul BruceDeveloper Advocate

Perfecto

Page 4: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

What We’ll Cover

1. Introductions to Espresso testing framework○ The pattern and some code samples○ Comparing Espresso and Appium

2. Improving build verification in CI○ Testing types and schedules○ Espresso on real devices in Jenkins

3. Pros & Cons of DIY lab setup○ Common pitfalls and requirements for success

4. Accelerating the feedback loop

Page 5: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Poll: Which UI testing technologies do you use?

● Espresso● Appium● Robotium● UI Automator● Other

Page 6: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Introductions to the Espresso test framework

IUsing Espresso for Fast and Reliable Feedback

Embedding quality across the Android lifecycle

Page 7: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Automated UI Testing for Android apps

● Creates folder for tests (androidTests)

● Adds Espresso libraries as dependencies

Page 8: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

On the surface, a fluent UI testing pattern

onData(ObjectMatcher).DataOptions.perform(ViewAction).check(ViewAssertion)

Find ItAct on ItCheck It

onView(Matcher).perform(ViewAction).check(ViewAssertion)

Page 9: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Espresso syntax in a nutshellFind

onView(withId(R.id.bill_value))

onView(allOf(withId(R.id.bill_value),isDisplayed()

))

// see ViewMatchers.

Act

.perform(replaceText(“25.44”))

.perform(click(), typeText(“...”)

)

.perform(pressBackButton())

.perform(swipeUp())

// see ViewActions.

Check

.check(matches(isDisplayed()))

.check(matches(not(isDisplayed())

))

.check(doesNotExist())

.check(matches(withText(“...”)))

// see ViewAssertions.

Page 10: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Espresso in Android Studio

Page 11: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

How ADB andinstrumentationwork together

Page 12: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

How does the alternative (Appium) work?

Page 13: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Pros/cons on both sidesEspresso/XCTest WebDriver...

Instrumented Black-box

Code+ XPath+

Ecosystem IndependentUpgrades

Execution

Object Locators

N YCross-platform

Depends+ Depends-Stability

bit.ly/oss-test-choices

Page 14: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Espresso avoids sleep() creep

Page 15: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Espresso avoids XPath delta breakage

Strings tell your compiler NOTHING!!!

No refactoring support

Can you write them properly...yes! Do you?

None of these things apply to compilable statements (i.e. R…).

Page 16: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

More Espresso getting started resources:

● Intro to Espresso and Spoonbit.ly/2kN4DAZ

● Vogella - Espresso Tutorialbit.ly/2l0y6lY

● Watch everything from Chiu Ki Chan on YouTube

● Tweet / email me with questions! @paulsbruce [email protected]

Page 17: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Improving build verification in CI

2Using Espresso for Fast and Reliable Feedback

Embedding quality across the Android lifecycle

Page 18: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Feedback loops across the pipeline

Page 19: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Complete feedback at the right times

Page 20: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Local Build Commit → Build Full / Nightly

Unit / New UI Integration / Smoke Full Regression

Fake Real Real

Static Mocks SandboxAPI

Tests

Hardware

A simple recipe for fast and complete feedback

< 2min < 20min < 2hr

Page 21: Using Espresso for Fast and Reliable Feedback

Espresso in Jenkins

Page 22: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Pros & cons of DIY lab setup

3Using Espresso for Fast and Reliable Feedback

Embedding quality across the Android lifecycle

Page 23: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Devices: local or cloud?

Local Build Merge → Build Full / Nightly

✓ ! ✘

! ✘ ✘

✓ ✓ ✓Cloud Lab

Emulator

Local Lab

Page 24: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Less hunting, more coding

● How many devices per developer?● In sync with the market?● Spares, adapters?● Storage/hosting/power costs?● Monitoring?● Security?

● High-volume automated testing● Big data from CI● Results retention & collaboration

Page 25: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Page 26: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Page 27: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Complete quality across the entire lifecycle

Page 28: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Accelerating the feedback loop

4Using Espresso for Fast and Reliable Feedback

Embedding quality across the Android lifecycle

Page 29: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Build verification, smoke tests

x5 per day * 4 critical platforms

Regression &end-to-end testing

nightly * 16 platforms + conditions

fast & complete feedback

Parallel testing requires a reliable, scalable lab

Page 30: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Fast feedback means a lab that fits into your workflow

bit.ly/perfecto-slack

Page 31: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Page 32: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Page 33: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

Page 34: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

A complete view of build quality

Page 35: Using Espresso for Fast and Reliable Feedback

Using Espresso for Fast and Reliable Feedback Web: perfectomobile.com Twitter: @perfectomobile

What We’ve Covered Today

1. Introductions to Espresso testing framework○ The pattern and some code samples○ Comparing Espresso and Appium

2. Improving build verification in CI○ Testing types and schedules○ Espresso on real devices in Jenkins

3. Pros & Cons of DIY lab setup○ Common pitfalls and requirements for success

4. Accelerating the feedback loop

Page 36: Using Espresso for Fast and Reliable Feedback

4 Ways to Speed Up Your Mobile/Web App Daily Grind Web: perfectomobile.com Twitter: @perfectomobile

Q&A .