SlideShare a Scribd company logo
1 of 103
Evolution of Octopus
Bian Jiang, Nirav Nagda
Uber Mobility Meetup
July 7, 2016
From cross-app/cross device testing, to network
record/replay, to scenario-based testing
Soon after we started at Uber, we encountered a fresh
testing challenge. Can you guess what it is?
Our Uber Challenge
Octopus: Our platform
agnostic test runner
GTAC 2015
Octopus Takes on the Uber Challenge of
Cross-app/Cross-device Testing
https://www.youtube.com/watch?v=p6gsssppeT0
Uber Eng Blog
https://eng.uber.com/rescued-by-octopus/
EndToEnd (L)
Scenario-based
Tests (M)
Unit Tests (S)
Top: small number of large end to
end tests (dozens)
Middle: middling amount of medium
integration tests (hundreds)
Bottom: large number of small unit
tests (thousands)
PREREQUISITES: HEALTHY TEST PYRAMID
Octopus Evolution
(Hermetic Tests)
Record mode:
- Records the network responses
Replay mode:
- Plays back the network responses from local files
HERMETIC TESTS: USING NETWORK RECORD/REPLAY
ANDROID EXAMPLE: NETWORK RECORD/REPLAY
@Test
@Replay
public void
whenDestinationPromptTap_shouldGoToLocationEditor() {
HomeLayout
.verifyLayout()
.clickDestinationPrompt();
}
(record = true)
func testFavoriteLocationsScreen() {
do {
launchAppWithOctopusConfig(try OctopusConfigBuilder()
.setNetworkReplayCache("rider_favorite_locations")
.setFakeLocation("555 Market St")
.build())
} catch {
print("Error when launching app")
}
login(withUsername: "fake_user", password: "fake_password")
let favoriteLocationsScreen = FavoriteLocaitonsScreen(
testCase: self,
application: application)
favoriteLocationsScreen.waitForRequiredElements()
}
IOS EXAMPLE: NETWORK RECORD/REPLAY
Octopus Demo
Octopus Evolution
(Rules & Scenario-based testing)
● What are rules?
● How do they help?
○ Easier test code
○ Shared setup/tearDown code logic
○ Abstract out the complicated logic from tests
UBER RULES
● Experiments
● Location
● Accounts
● Animations
● App reset
RULES EXAMPLES
EXAMPLE: LOCATION RULE
@Location (device = TestLocation.CHICAGO_SUBURB)
@Replay
@Test
public void whenValidAccount_shouldBeAbleToSignIn() {
WelcomeLayout
.verifyLayout()
.clickLogin();
LoginLayout
.verifyLayout()
.signInWith(Account.GENERIC.getEmail(),
Account.GENERIC.getPassword());
RideLayout.verifyLayout();
}
● What is scenario-based testing?
● How does it help?
○ Speeds up the test run
○ Easier to maintain
○ Deterministic tests
SCENARIO-BASED TESTING
SCENARIO-BASED TESTING: ANDROID EXAMPLE
Only when
recording
Actual test
public void cancelTripRequest() {
replayScenarioManager.doWhenRecording(new Interactions() {
@Override
public void perform() {
AcceleratorsLayout.verifyLayout().clickItem(0);
ProductSelectionLayout.verifyLayout().swipeToIndex(1)
.clickProduct(R.string.uberx);
ConfirmationLayout.verifyLayout().clickGo();
}
});
// The test will start from here in replay mode.
DispatchingLayout.verifyLayout().clickCancel();
ConfirmationLayout.verifyLayout();
}
Special thanks to mobile-test-platform@,
octopus-eng@, mobile-eng@ and all the
amazing people at Uber :)
Uber eng blog
https://eng.uber.com/rescued-by-octopus/
GTAC talk on Octopus
https://www.youtube.com/watch?v=p6gsssppeT0
How an "ideal" CI setup for mobile looks like
Valera Zakharov
Ideal =
Reliable
Scalable
Performant
Controllable
Debuggable
On Mobile
Different screen resolutions
Different OS versions
On Android
Need Android Runtime to run
instrumentation tests
$ adb shell am instrument -w
<test_package_name>/<runner_cla
ss>
Basic Building Blocks
Orchestration Device
ADB
Host (build node)
Ideal Orchestration
Obtains/releases a device
Sets up the device for testing
Issues ‘adb shell am instrument’ calls for each test
Collects debug info
Ideal Android Debug Bridge
Issue shell commands
Install apks
Push data to device
Pull data from device
Does all of the above reliably and quickly
Device
Ideal Test Device
Starts reliably and quickly
Runs as fast as top-of the line phone
Allows you to scale
Provides tests with control over system settings
Test Services
Prevents UI popups
Android Vanilla Setup
Orchestration
Jenkins or another equivalent
./gradlew connectedCheck
Adb
Stock
Device
Locally connected emulator or physical device
Vanilla Setup Problems
Orchestration
one process for all tests
no sharding
no separate logcat/debug info
Adb
Slow
Vanilla Setup Problems
Device
Not test friendly
Physical devices
not designed for CI usage
hard to maintain and scale
Emulator:
hard to configure properly
system images not well maintained
Ideal =
Reliable
Scalable
Performant
Controllable
Debuggable
Google’s Internal Setup
Orchestration
Custom (hooked into the internal build system)
Adb
adb.turbo ™
Device
Stock x86 emulator running in dedicated data-center machines
Properly configured/maintained
Config abstracted away by a script
Existing services come up short
Firebase Google Cloud Test Lab
Runs all tests in one instrumentation
Virtual Devices are slow
Not debuggable
Xamarin
Doesn’t run instrumentation tests
AWS
Runs all tests in one instrumentation
So… now what
¯_(ツ)_/¯
Some thoughts...
Orchestration
Tools for discovering tests in an apk (based on dexdump)
An alternative to ./gradlew connectedCheck
android_test --apk my.apk --tests test.apk
ADB
adb.turbo (or equivalent) if planning to run at Google-scale
Device
Custom IActivityController
Faster Tests with Test Parallelization
JUSTIN MARTIN & DANIEL RIBEIRO
Too many tests? No such
thing!
~150 minutes
~50 minutes
MACHINE TIME WALL TIME
Distributed vs.
Non-distributed
~150 minutes
~125 minutes
~50 minutes
MACHINE TIME WALL TIME
NON-DISTRIBUTED DISTRIBUTED
Distributed vs.
Non-distributed
~150 minutes
~125 minutes
~50 minutes
MACHINE TIME WALL TIME
~20 minutes
Distributed vs.
Non-distributed
NON-DISTRIBUTED DISTRIBUTED
Separation of
Powers
BUILD TEST
Separation of
Powers
BUILD
MAC PROS
TEST
MAC MINIS
Reruns Are Even Faster!
PRO TIME MINI TIME
MACHINE TIME
(RERUN)
WALL TIME
(RERUN)
XCKnife
FASTER DISTRIBUTED TESTS FOR iOS
GITHUB.COM/SQUARE/XCKNIFE
SQU.RE/XCKNIFE
Each iteration takes a test class from the queue and assigns it to the machine that is the
least busy
XCKnife
Balancing
Balanced
Sharding
Approximate
Key takeaways
Disclaimer
Diminishing
Returns
Testing Pyramid
Testing Pyramid
Testing Matrix
Many devices
Testing Matrix:
OS versions
Testing Matrix:
Orientations
Testing Matrix:
localizations
Testing Matrix:
Test Explosion
It is distributed
Availability
Operations matter
Test your
infrastructure
Everything breaks
When you fix,
please open source
it
Toolchain
UX
Matters
Bad actors
Justin Martin
Daniel Ribeiro
jmartin@squareup.com
danielrb@squareup.com
3x3: Speeding Up Mobile
Releases
Drew Hannay (@drewhannay)
Project Voyager
New version of flagship
LinkedIn app
250+ committers across
Android & iOS
~1 year of development
Investment in mobile
infrastructure at
LinkedIn
Before Voyager
12 releases per year
RC build + manual regression suite
Mad dash to commit code before the RC cutoff
Missing the cutoff meant a long wait for the next release
Product & marketing plans were made around the monthly releases
Hard to iterate on member feedback
3x3
Release three times per day, no more than three
hours from code commit to member availability
Why three hours?
Not enough time for manual testing steps
Not enough time to test everything
The goal isn’t 100% automation, it’s faster iterations
We don’t want engineers spending most of their time maintaining tests that break whenever a
design changes
UI tests are chosen based on production-critical business flows
Faster iteration helps emphasize craftsmanship
Devs can take the extra time to write quality code since the next release is soon
Commit Pipeline
Code
Review
Static
Analysis
Unit
Tests
Build
Release
Artifacts
UI
Tests
Alpha
Release
Feature
Development
Production
Release
Beta
Release
Commit Pipeline
Code
Review
Static
Analysis
Unit
Tests
Build
Release
Artifacts
UI
Tests
Alpha
Release
Feature
Development
Production
Release
Beta
Release
Static analysis
Compile-time contract with API server using Rest.li
Rest.li data templates are shared between API server & clients
Provides static analysis checks that guarantee backwards compatibility
Client models are code generated for further safety
Java Checkstyle
Android Lint
Over 200 checks provided by Google
Several custom checks written for LinkedIn-specific patterns
Building the code
Over 500k lines of code between Android & iOS
Building production binaries for a large codebase is slow
iOS & Swift
At one point early on, Swift compilation took over two hours
Refactoring into sub-projects and modules lead to a more than 50% speed up
Android Split APKs
Separate binary for each combination of screen density and CPU architecture
Distributed builds
What do we test?
Unit tests
Layout tests
Unit tests for views
Stress test views with long strings, short strings
Make sure views don’t overlap, and render properly in right-to-left mode
Scenario tests
Validate that key business metric flows are working properly
Usually flows that span multiple screens in the app
Test stability
UI tests use Android Espresso & iOS KIF frameworks
Needed to create a consistent test environment across dev & build machines
Android
Self-contained, standardized Android emulator bundle
Custom test harness that runs one test per application launch
iOS
KIF contained hard-coded waits that passed on dev boxes, but failed on slower build servers
Forked KIF to convert to a checkpoint-based system,
where the code tells the test when to proceed to the next step
Test speed
Android
Use Espresso’s IdlingResource API to avoid sleeps and waits
Run up to 16 Android emulators in parallel on a single build machine
Custom test harness allows optimal test parallelization
iOS
Refactoring KIF cut UI testing time by more than 80%
Distributed testing -> Shard tests across multiple machines
Significantly faster, but led to greater exposure to any tooling instability
Android multi-emulator test run
iOS KIF refactoring
iOS multi-simulator testing
Partner teams
Historically, several partner teams validated the
build before a release
For example, we needed sign off from the
localization team
Lint checks catch hardcoded or improperly
formatted strings
Layout tests catch strings that are too long and
RTL layout bugs
Semantic correctness of translations is still
validated by translators manually
Getting to members
Every three hours, internal alpha testers get a new build
Mainly members of the Flagship team
Product managers, devs, and execs who want to see the latest code ASAP
Every week, the rest of the company gets a new beta build
iOS build is submitted to Apple for review
After a week of beta, the build is promoted to production
Assuming Apple’s review is complete, iOS is released
Take advantage of Google Play staged rollout for Android
Dogfooding
Android: Google Play alpha/beta channel
Easy upgrades for employees, even while off the corporate network
Somewhat difficult to get set up, but easy once registered
iOS: TestFlight
Nice, but limited number of users
iOS: Custom enterprise distribution
Scales to our number of users, but employees must be on corporate wifi to upgrade
Splash screen in the production app encourages employees to use beta builds
Minimizing risk & enabling experiments
Take advantage of LinkedIn’s existing A/B testing infrastructure
New features are developed behind feature flags
Code can be ramped dynamically to different groups of members
Performance of new features or changes can be monitored
Dynamic configuration
Server-controlled kill switch
Crashing or buggy code can often be disabled without a new build
3x3 after 6 months: areas to improve
Release automation
Production uploads to the app stores are still a manual process
Getting release notes & translations is painful
Automated performance testing
We can sample performance of the app in production,
but don’t have a great way of catching issues before release
Android Monkey testing
Enables wide range of API level & device coverage with very low overhead cost
iOS speed improvements
Questions
3x3 blogs & videos
3x3: Speeding up mobile releases
3x3: iOS Build Speed and Stability
Test Stability - How We Make UI Tests Stable
UI Automation: Keep it Functional - and Stable!
Consistent Android Testing Environments with Gradle (slides)
Effective Layout Testing Library for iOS
Managing iOS Continuous Integration at Enterprise Scale
Uber Mobility Meetup:  Mobile Testing

More Related Content

What's hot

5 Mobile App Trends & What They Mean for Dev & Testing
5 Mobile App Trends & What They Mean for Dev & Testing5 Mobile App Trends & What They Mean for Dev & Testing
5 Mobile App Trends & What They Mean for Dev & TestingPerfecto by Perforce
 
Testdroid: Release Perfect Apps with Mobile Visual Testing in the Cloud
Testdroid: Release Perfect Apps with Mobile Visual Testing in the Cloud Testdroid: Release Perfect Apps with Mobile Visual Testing in the Cloud
Testdroid: Release Perfect Apps with Mobile Visual Testing in the Cloud Applitools
 
Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Bitbar
 
Appium & Selenium Alone vs Appium & Selenium with Perfecto
Appium & Selenium Alone vs Appium & Selenium with PerfectoAppium & Selenium Alone vs Appium & Selenium with Perfecto
Appium & Selenium Alone vs Appium & Selenium with PerfectoLizzy Guido (she/her)
 
Webinar learn how to test any mobile app style from within eclipse using real...
Webinar learn how to test any mobile app style from within eclipse using real...Webinar learn how to test any mobile app style from within eclipse using real...
Webinar learn how to test any mobile app style from within eclipse using real...Perfecto Mobile
 
Cloud Testing Has Never Been Easier or More Accessible
Cloud Testing Has Never Been Easier or More AccessibleCloud Testing Has Never Been Easier or More Accessible
Cloud Testing Has Never Been Easier or More AccessiblePerfecto by Perforce
 
Testing Techniques for Mobile Applications
Testing Techniques for Mobile ApplicationsTesting Techniques for Mobile Applications
Testing Techniques for Mobile ApplicationsIndicThreads
 
The ultimate guide to mobile app testing with appium
The ultimate guide to mobile app testing with appiumThe ultimate guide to mobile app testing with appium
The ultimate guide to mobile app testing with appiumheadspin2
 
Accelerating Digital Transformation With API Lifecycle & Test Automation
Accelerating Digital Transformation With API Lifecycle & Test AutomationAccelerating Digital Transformation With API Lifecycle & Test Automation
Accelerating Digital Transformation With API Lifecycle & Test AutomationPerfecto by Perforce
 
iOS Automation Frameworks evaluation
iOS Automation Frameworks evaluationiOS Automation Frameworks evaluation
iOS Automation Frameworks evaluationSerghei Moret
 
Cross Platform Mobile Test Automation using Selenium WebDriver by Perfecto Mo...
Cross Platform Mobile Test Automation using Selenium WebDriver by Perfecto Mo...Cross Platform Mobile Test Automation using Selenium WebDriver by Perfecto Mo...
Cross Platform Mobile Test Automation using Selenium WebDriver by Perfecto Mo...Perfecto Mobile
 
Automated Testing and Continuous Deployment for Mobile Apps with Jenkins
Automated Testing and Continuous Deployment for Mobile Apps with Jenkins Automated Testing and Continuous Deployment for Mobile Apps with Jenkins
Automated Testing and Continuous Deployment for Mobile Apps with Jenkins CloudBees
 
Appium tips & Inneractive integration
Appium tips & Inneractive integrationAppium tips & Inneractive integration
Appium tips & Inneractive integrationGil Sheps
 
How to Test Security and Vulnerability of Your Android and iOS Apps
How to Test Security and Vulnerability of Your Android and iOS AppsHow to Test Security and Vulnerability of Your Android and iOS Apps
How to Test Security and Vulnerability of Your Android and iOS AppsBitbar
 
Managing Continuous Delivery of Mobile Apps - for the Enterprise
Managing Continuous Delivery of Mobile Apps - for the EnterpriseManaging Continuous Delivery of Mobile Apps - for the Enterprise
Managing Continuous Delivery of Mobile Apps - for the EnterpriseSauce Labs
 
Hassle-Free Continuous Integration with Real Device Testing
Hassle-Free Continuous Integration with Real Device TestingHassle-Free Continuous Integration with Real Device Testing
Hassle-Free Continuous Integration with Real Device TestingBitbar
 
Mobile applications and automation testing
Mobile applications and automation testingMobile applications and automation testing
Mobile applications and automation testingIndicThreads
 
Mobile Application Testing
Mobile Application Testing Mobile Application Testing
Mobile Application Testing Shivaraj R
 

What's hot (20)

5 Mobile App Trends & What They Mean for Dev & Testing
5 Mobile App Trends & What They Mean for Dev & Testing5 Mobile App Trends & What They Mean for Dev & Testing
5 Mobile App Trends & What They Mean for Dev & Testing
 
Testdroid: Release Perfect Apps with Mobile Visual Testing in the Cloud
Testdroid: Release Perfect Apps with Mobile Visual Testing in the Cloud Testdroid: Release Perfect Apps with Mobile Visual Testing in the Cloud
Testdroid: Release Perfect Apps with Mobile Visual Testing in the Cloud
 
Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?
 
Appium & Selenium Alone vs Appium & Selenium with Perfecto
Appium & Selenium Alone vs Appium & Selenium with PerfectoAppium & Selenium Alone vs Appium & Selenium with Perfecto
Appium & Selenium Alone vs Appium & Selenium with Perfecto
 
Webinar learn how to test any mobile app style from within eclipse using real...
Webinar learn how to test any mobile app style from within eclipse using real...Webinar learn how to test any mobile app style from within eclipse using real...
Webinar learn how to test any mobile app style from within eclipse using real...
 
Cloud Testing Has Never Been Easier or More Accessible
Cloud Testing Has Never Been Easier or More AccessibleCloud Testing Has Never Been Easier or More Accessible
Cloud Testing Has Never Been Easier or More Accessible
 
Testing Techniques for Mobile Applications
Testing Techniques for Mobile ApplicationsTesting Techniques for Mobile Applications
Testing Techniques for Mobile Applications
 
The ultimate guide to mobile app testing with appium
The ultimate guide to mobile app testing with appiumThe ultimate guide to mobile app testing with appium
The ultimate guide to mobile app testing with appium
 
Accelerating Digital Transformation With API Lifecycle & Test Automation
Accelerating Digital Transformation With API Lifecycle & Test AutomationAccelerating Digital Transformation With API Lifecycle & Test Automation
Accelerating Digital Transformation With API Lifecycle & Test Automation
 
iOS Automation Frameworks evaluation
iOS Automation Frameworks evaluationiOS Automation Frameworks evaluation
iOS Automation Frameworks evaluation
 
Cross Platform Mobile Test Automation using Selenium WebDriver by Perfecto Mo...
Cross Platform Mobile Test Automation using Selenium WebDriver by Perfecto Mo...Cross Platform Mobile Test Automation using Selenium WebDriver by Perfecto Mo...
Cross Platform Mobile Test Automation using Selenium WebDriver by Perfecto Mo...
 
Automated Testing and Continuous Deployment for Mobile Apps with Jenkins
Automated Testing and Continuous Deployment for Mobile Apps with Jenkins Automated Testing and Continuous Deployment for Mobile Apps with Jenkins
Automated Testing and Continuous Deployment for Mobile Apps with Jenkins
 
Mobile Monitoring Best Practices
Mobile Monitoring Best PracticesMobile Monitoring Best Practices
Mobile Monitoring Best Practices
 
Appium tips & Inneractive integration
Appium tips & Inneractive integrationAppium tips & Inneractive integration
Appium tips & Inneractive integration
 
How to Test Security and Vulnerability of Your Android and iOS Apps
How to Test Security and Vulnerability of Your Android and iOS AppsHow to Test Security and Vulnerability of Your Android and iOS Apps
How to Test Security and Vulnerability of Your Android and iOS Apps
 
Yauheni_Semchanka_CV
Yauheni_Semchanka_CVYauheni_Semchanka_CV
Yauheni_Semchanka_CV
 
Managing Continuous Delivery of Mobile Apps - for the Enterprise
Managing Continuous Delivery of Mobile Apps - for the EnterpriseManaging Continuous Delivery of Mobile Apps - for the Enterprise
Managing Continuous Delivery of Mobile Apps - for the Enterprise
 
Hassle-Free Continuous Integration with Real Device Testing
Hassle-Free Continuous Integration with Real Device TestingHassle-Free Continuous Integration with Real Device Testing
Hassle-Free Continuous Integration with Real Device Testing
 
Mobile applications and automation testing
Mobile applications and automation testingMobile applications and automation testing
Mobile applications and automation testing
 
Mobile Application Testing
Mobile Application Testing Mobile Application Testing
Mobile Application Testing
 

Similar to Uber Mobility Meetup: Mobile Testing

Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...Applitools
 
Android developer's toolbox
Android developer's toolboxAndroid developer's toolbox
Android developer's toolboxAlex Verdyan
 
Webinar: Automate Your Environment Provisioning for Mobile App Development
Webinar: Automate Your Environment Provisioning for Mobile App Development Webinar: Automate Your Environment Provisioning for Mobile App Development
Webinar: Automate Your Environment Provisioning for Mobile App Development Skytap Cloud
 
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with AppiumSrijan Technologies
 
A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"DataArt
 
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)Bitbar
 
利用 Appium + Robot Framework 實現跨平台 App 互動測試
利用 Appium + Robot Framework 實現跨平台 App 互動測試利用 Appium + Robot Framework 實現跨平台 App 互動測試
利用 Appium + Robot Framework 實現跨平台 App 互動測試Jeremy Kao
 
Selenium Israel Meetup
Selenium Israel MeetupSelenium Israel Meetup
Selenium Israel MeetupJustin Ison
 
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaCloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaAmazon Web Services
 
Velocity Conference: Increasing Speed To Market In Mobile Development Through...
Velocity Conference: Increasing Speed To Market In Mobile Development Through...Velocity Conference: Increasing Speed To Market In Mobile Development Through...
Velocity Conference: Increasing Speed To Market In Mobile Development Through...Intuit Inc.
 
Testing distributed systems in production
Testing distributed systems in productionTesting distributed systems in production
Testing distributed systems in productionPaul Bakker
 
DCAST Meetup - Washington, DC Feb 2016
DCAST Meetup - Washington, DC Feb 2016DCAST Meetup - Washington, DC Feb 2016
DCAST Meetup - Washington, DC Feb 2016Justin Ison
 
Selenium Camp 2016 - Kiev, Ukraine
Selenium Camp 2016 -  Kiev, UkraineSelenium Camp 2016 -  Kiev, Ukraine
Selenium Camp 2016 - Kiev, UkraineJustin Ison
 
Selenium2 and Jenkins: Almost pain-free UI Testing
Selenium2 and Jenkins: Almost pain-free UI TestingSelenium2 and Jenkins: Almost pain-free UI Testing
Selenium2 and Jenkins: Almost pain-free UI Testingmikereedell
 
Our DevOps Journey: 6 Month Waterfalls to 1 Hour Code Deploys
Our DevOps Journey: 6 Month Waterfalls to 1 Hour Code DeploysOur DevOps Journey: 6 Month Waterfalls to 1 Hour Code Deploys
Our DevOps Journey: 6 Month Waterfalls to 1 Hour Code DeploysDynatrace
 
Velocity2013 mobile ci_intuit
Velocity2013 mobile ci_intuitVelocity2013 mobile ci_intuit
Velocity2013 mobile ci_intuitTina Su
 
Speed to Market in Mobile Development
Speed to Market in Mobile DevelopmentSpeed to Market in Mobile Development
Speed to Market in Mobile DevelopmentTina Su
 
Velocity2013 mobile ci_intuit
Velocity2013 mobile ci_intuitVelocity2013 mobile ci_intuit
Velocity2013 mobile ci_intuitTina Su
 
The Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native AppsThe Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native AppsSauce Labs
 

Similar to Uber Mobility Meetup: Mobile Testing (20)

Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
Shifting landscape of mobile automation, and the future of Appium - Jonathan ...
 
Android developer's toolbox
Android developer's toolboxAndroid developer's toolbox
Android developer's toolbox
 
Webinar: Automate Your Environment Provisioning for Mobile App Development
Webinar: Automate Your Environment Provisioning for Mobile App Development Webinar: Automate Your Environment Provisioning for Mobile App Development
Webinar: Automate Your Environment Provisioning for Mobile App Development
 
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
 
A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"
 
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
 
利用 Appium + Robot Framework 實現跨平台 App 互動測試
利用 Appium + Robot Framework 實現跨平台 App 互動測試利用 Appium + Robot Framework 實現跨平台 App 互動測試
利用 Appium + Robot Framework 實現跨平台 App 互動測試
 
Selenium Israel Meetup
Selenium Israel MeetupSelenium Israel Meetup
Selenium Israel Meetup
 
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaCloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
 
Velocity Conference: Increasing Speed To Market In Mobile Development Through...
Velocity Conference: Increasing Speed To Market In Mobile Development Through...Velocity Conference: Increasing Speed To Market In Mobile Development Through...
Velocity Conference: Increasing Speed To Market In Mobile Development Through...
 
Testing distributed systems in production
Testing distributed systems in productionTesting distributed systems in production
Testing distributed systems in production
 
DCAST Meetup - Washington, DC Feb 2016
DCAST Meetup - Washington, DC Feb 2016DCAST Meetup - Washington, DC Feb 2016
DCAST Meetup - Washington, DC Feb 2016
 
Selenium Camp 2016 - Kiev, Ukraine
Selenium Camp 2016 -  Kiev, UkraineSelenium Camp 2016 -  Kiev, Ukraine
Selenium Camp 2016 - Kiev, Ukraine
 
Mobile Testing
Mobile TestingMobile Testing
Mobile Testing
 
Selenium2 and Jenkins: Almost pain-free UI Testing
Selenium2 and Jenkins: Almost pain-free UI TestingSelenium2 and Jenkins: Almost pain-free UI Testing
Selenium2 and Jenkins: Almost pain-free UI Testing
 
Our DevOps Journey: 6 Month Waterfalls to 1 Hour Code Deploys
Our DevOps Journey: 6 Month Waterfalls to 1 Hour Code DeploysOur DevOps Journey: 6 Month Waterfalls to 1 Hour Code Deploys
Our DevOps Journey: 6 Month Waterfalls to 1 Hour Code Deploys
 
Velocity2013 mobile ci_intuit
Velocity2013 mobile ci_intuitVelocity2013 mobile ci_intuit
Velocity2013 mobile ci_intuit
 
Speed to Market in Mobile Development
Speed to Market in Mobile DevelopmentSpeed to Market in Mobile Development
Speed to Market in Mobile Development
 
Velocity2013 mobile ci_intuit
Velocity2013 mobile ci_intuitVelocity2013 mobile ci_intuit
Velocity2013 mobile ci_intuit
 
The Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native AppsThe Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native Apps
 

Uber Mobility Meetup: Mobile Testing

  • 1.
  • 2. Evolution of Octopus Bian Jiang, Nirav Nagda Uber Mobility Meetup July 7, 2016 From cross-app/cross device testing, to network record/replay, to scenario-based testing
  • 3. Soon after we started at Uber, we encountered a fresh testing challenge. Can you guess what it is? Our Uber Challenge
  • 5. GTAC 2015 Octopus Takes on the Uber Challenge of Cross-app/Cross-device Testing https://www.youtube.com/watch?v=p6gsssppeT0 Uber Eng Blog https://eng.uber.com/rescued-by-octopus/
  • 6. EndToEnd (L) Scenario-based Tests (M) Unit Tests (S) Top: small number of large end to end tests (dozens) Middle: middling amount of medium integration tests (hundreds) Bottom: large number of small unit tests (thousands) PREREQUISITES: HEALTHY TEST PYRAMID
  • 8. Record mode: - Records the network responses Replay mode: - Plays back the network responses from local files HERMETIC TESTS: USING NETWORK RECORD/REPLAY
  • 9. ANDROID EXAMPLE: NETWORK RECORD/REPLAY @Test @Replay public void whenDestinationPromptTap_shouldGoToLocationEditor() { HomeLayout .verifyLayout() .clickDestinationPrompt(); } (record = true)
  • 10. func testFavoriteLocationsScreen() { do { launchAppWithOctopusConfig(try OctopusConfigBuilder() .setNetworkReplayCache("rider_favorite_locations") .setFakeLocation("555 Market St") .build()) } catch { print("Error when launching app") } login(withUsername: "fake_user", password: "fake_password") let favoriteLocationsScreen = FavoriteLocaitonsScreen( testCase: self, application: application) favoriteLocationsScreen.waitForRequiredElements() } IOS EXAMPLE: NETWORK RECORD/REPLAY
  • 12.
  • 13. Octopus Evolution (Rules & Scenario-based testing)
  • 14. ● What are rules? ● How do they help? ○ Easier test code ○ Shared setup/tearDown code logic ○ Abstract out the complicated logic from tests UBER RULES
  • 15. ● Experiments ● Location ● Accounts ● Animations ● App reset RULES EXAMPLES
  • 16. EXAMPLE: LOCATION RULE @Location (device = TestLocation.CHICAGO_SUBURB) @Replay @Test public void whenValidAccount_shouldBeAbleToSignIn() { WelcomeLayout .verifyLayout() .clickLogin(); LoginLayout .verifyLayout() .signInWith(Account.GENERIC.getEmail(), Account.GENERIC.getPassword()); RideLayout.verifyLayout(); }
  • 17. ● What is scenario-based testing? ● How does it help? ○ Speeds up the test run ○ Easier to maintain ○ Deterministic tests SCENARIO-BASED TESTING
  • 18. SCENARIO-BASED TESTING: ANDROID EXAMPLE Only when recording Actual test public void cancelTripRequest() { replayScenarioManager.doWhenRecording(new Interactions() { @Override public void perform() { AcceleratorsLayout.verifyLayout().clickItem(0); ProductSelectionLayout.verifyLayout().swipeToIndex(1) .clickProduct(R.string.uberx); ConfirmationLayout.verifyLayout().clickGo(); } }); // The test will start from here in replay mode. DispatchingLayout.verifyLayout().clickCancel(); ConfirmationLayout.verifyLayout(); }
  • 19. Special thanks to mobile-test-platform@, octopus-eng@, mobile-eng@ and all the amazing people at Uber :) Uber eng blog https://eng.uber.com/rescued-by-octopus/ GTAC talk on Octopus https://www.youtube.com/watch?v=p6gsssppeT0
  • 20.
  • 21. How an "ideal" CI setup for mobile looks like Valera Zakharov
  • 22.
  • 23.
  • 24.
  • 26. On Mobile Different screen resolutions Different OS versions
  • 27. On Android Need Android Runtime to run instrumentation tests $ adb shell am instrument -w <test_package_name>/<runner_cla ss>
  • 28. Basic Building Blocks Orchestration Device ADB Host (build node)
  • 29. Ideal Orchestration Obtains/releases a device Sets up the device for testing Issues ‘adb shell am instrument’ calls for each test Collects debug info
  • 30. Ideal Android Debug Bridge Issue shell commands Install apks Push data to device Pull data from device Does all of the above reliably and quickly
  • 32. Ideal Test Device Starts reliably and quickly Runs as fast as top-of the line phone Allows you to scale Provides tests with control over system settings Test Services Prevents UI popups
  • 33. Android Vanilla Setup Orchestration Jenkins or another equivalent ./gradlew connectedCheck Adb Stock Device Locally connected emulator or physical device
  • 34. Vanilla Setup Problems Orchestration one process for all tests no sharding no separate logcat/debug info Adb Slow
  • 35. Vanilla Setup Problems Device Not test friendly Physical devices not designed for CI usage hard to maintain and scale Emulator: hard to configure properly system images not well maintained
  • 37. Google’s Internal Setup Orchestration Custom (hooked into the internal build system) Adb adb.turbo ™ Device Stock x86 emulator running in dedicated data-center machines Properly configured/maintained Config abstracted away by a script
  • 38.
  • 39. Existing services come up short Firebase Google Cloud Test Lab Runs all tests in one instrumentation Virtual Devices are slow Not debuggable Xamarin Doesn’t run instrumentation tests AWS Runs all tests in one instrumentation
  • 41. Some thoughts... Orchestration Tools for discovering tests in an apk (based on dexdump) An alternative to ./gradlew connectedCheck android_test --apk my.apk --tests test.apk ADB adb.turbo (or equivalent) if planning to run at Google-scale Device Custom IActivityController
  • 42.
  • 43.
  • 44. Faster Tests with Test Parallelization JUSTIN MARTIN & DANIEL RIBEIRO
  • 45. Too many tests? No such thing!
  • 46. ~150 minutes ~50 minutes MACHINE TIME WALL TIME Distributed vs. Non-distributed
  • 47. ~150 minutes ~125 minutes ~50 minutes MACHINE TIME WALL TIME NON-DISTRIBUTED DISTRIBUTED Distributed vs. Non-distributed
  • 48. ~150 minutes ~125 minutes ~50 minutes MACHINE TIME WALL TIME ~20 minutes Distributed vs. Non-distributed NON-DISTRIBUTED DISTRIBUTED
  • 51.
  • 52. Reruns Are Even Faster! PRO TIME MINI TIME MACHINE TIME (RERUN) WALL TIME (RERUN)
  • 53. XCKnife FASTER DISTRIBUTED TESTS FOR iOS GITHUB.COM/SQUARE/XCKNIFE SQU.RE/XCKNIFE
  • 54.
  • 55. Each iteration takes a test class from the queue and assigns it to the machine that is the least busy XCKnife Balancing
  • 58.
  • 75. When you fix, please open source it
  • 80.
  • 81. 3x3: Speeding Up Mobile Releases Drew Hannay (@drewhannay)
  • 82. Project Voyager New version of flagship LinkedIn app 250+ committers across Android & iOS ~1 year of development Investment in mobile infrastructure at LinkedIn
  • 83. Before Voyager 12 releases per year RC build + manual regression suite Mad dash to commit code before the RC cutoff Missing the cutoff meant a long wait for the next release Product & marketing plans were made around the monthly releases Hard to iterate on member feedback
  • 84. 3x3 Release three times per day, no more than three hours from code commit to member availability
  • 85. Why three hours? Not enough time for manual testing steps Not enough time to test everything The goal isn’t 100% automation, it’s faster iterations We don’t want engineers spending most of their time maintaining tests that break whenever a design changes UI tests are chosen based on production-critical business flows Faster iteration helps emphasize craftsmanship Devs can take the extra time to write quality code since the next release is soon
  • 88. Static analysis Compile-time contract with API server using Rest.li Rest.li data templates are shared between API server & clients Provides static analysis checks that guarantee backwards compatibility Client models are code generated for further safety Java Checkstyle Android Lint Over 200 checks provided by Google Several custom checks written for LinkedIn-specific patterns
  • 89. Building the code Over 500k lines of code between Android & iOS Building production binaries for a large codebase is slow iOS & Swift At one point early on, Swift compilation took over two hours Refactoring into sub-projects and modules lead to a more than 50% speed up Android Split APKs Separate binary for each combination of screen density and CPU architecture Distributed builds
  • 90. What do we test? Unit tests Layout tests Unit tests for views Stress test views with long strings, short strings Make sure views don’t overlap, and render properly in right-to-left mode Scenario tests Validate that key business metric flows are working properly Usually flows that span multiple screens in the app
  • 91. Test stability UI tests use Android Espresso & iOS KIF frameworks Needed to create a consistent test environment across dev & build machines Android Self-contained, standardized Android emulator bundle Custom test harness that runs one test per application launch iOS KIF contained hard-coded waits that passed on dev boxes, but failed on slower build servers Forked KIF to convert to a checkpoint-based system, where the code tells the test when to proceed to the next step
  • 92. Test speed Android Use Espresso’s IdlingResource API to avoid sleeps and waits Run up to 16 Android emulators in parallel on a single build machine Custom test harness allows optimal test parallelization iOS Refactoring KIF cut UI testing time by more than 80% Distributed testing -> Shard tests across multiple machines Significantly faster, but led to greater exposure to any tooling instability
  • 96. Partner teams Historically, several partner teams validated the build before a release For example, we needed sign off from the localization team Lint checks catch hardcoded or improperly formatted strings Layout tests catch strings that are too long and RTL layout bugs Semantic correctness of translations is still validated by translators manually
  • 97. Getting to members Every three hours, internal alpha testers get a new build Mainly members of the Flagship team Product managers, devs, and execs who want to see the latest code ASAP Every week, the rest of the company gets a new beta build iOS build is submitted to Apple for review After a week of beta, the build is promoted to production Assuming Apple’s review is complete, iOS is released Take advantage of Google Play staged rollout for Android
  • 98. Dogfooding Android: Google Play alpha/beta channel Easy upgrades for employees, even while off the corporate network Somewhat difficult to get set up, but easy once registered iOS: TestFlight Nice, but limited number of users iOS: Custom enterprise distribution Scales to our number of users, but employees must be on corporate wifi to upgrade Splash screen in the production app encourages employees to use beta builds
  • 99. Minimizing risk & enabling experiments Take advantage of LinkedIn’s existing A/B testing infrastructure New features are developed behind feature flags Code can be ramped dynamically to different groups of members Performance of new features or changes can be monitored Dynamic configuration Server-controlled kill switch Crashing or buggy code can often be disabled without a new build
  • 100. 3x3 after 6 months: areas to improve Release automation Production uploads to the app stores are still a manual process Getting release notes & translations is painful Automated performance testing We can sample performance of the app in production, but don’t have a great way of catching issues before release Android Monkey testing Enables wide range of API level & device coverage with very low overhead cost iOS speed improvements
  • 102. 3x3 blogs & videos 3x3: Speeding up mobile releases 3x3: iOS Build Speed and Stability Test Stability - How We Make UI Tests Stable UI Automation: Keep it Functional - and Stable! Consistent Android Testing Environments with Gradle (slides) Effective Layout Testing Library for iOS Managing iOS Continuous Integration at Enterprise Scale