SlideShare a Scribd company logo
TESTING ANDROID APPS
Android-centric architecture vs. unit-testable android apps
PAUL WEIN
Consultant
Mobile Architect
150 8 +850
Offices EmployeesActive Clients
What Where
Netlight operates throughout Europe with
offices in Stockholm, Oslo, Munich,
Helsinki, Hamburg, Berlin, Paris and
London.
How
Founded in Stockholm, Sweden, since
1999, Netlight has helped leaders in the
digital industry to realise business critical
projects in the forefront of technology.
Netlight is an international consultancy firm
that offers a full range of services with a
focus on Technology and IT-Management.
Continuous	integration
Unit	tests
Instrumentation	tests
Code	review
Code	coverage
Test	driven	development
Behavior	driven	development
Static	code	analysis
Usability	tests
Test	documentation
Test	reports
Crashtracking
System	tests
Back	box	tests
White	box	tests
Security	tests
Load	tests
QA SHOULD BE PART
OF THE MINDSET OF A
DEVELOPER, EVEN
BEFORE HE STARTS
WRITING CODE.
Android-centric-architecture vs. unit testable apps
If you don't test your software your users will!
Agenda
‣ Why has testing been so hard?
‣ Android-centric architecture
‣ Model-View-Presenter (MVP)
‣ Model-View-ViewModel (MVVM)
‣ Model-View-Intent (MVI)
‣ Tools
Why has testing Android Apps been so hard?
Testable code requires layers
of abstraction, which have a
performance cost
Performance Concerns
Misunderstanding
Android Components
Don’t architect your app
around system components
(Activities, Services,
Broadcast Receivers,
Content Providers)
The rise of TDD
Test-driven development
was on the rise at the same
time Android was
App building blocks
Intent
ServiceContent	Provider
Broadcast	
Receiver
Activity Fragment
Android-centric architecture
Activity
Lifecycle	Events
Business	Rules
Access	Hardware
Access	Sensors
Framework	APIs
….
• Mix presentation logic
with business rules
• Code is difficult to
understand
• To rigid to handle
varying use-cases
• Tight coupling & low
cohesion
Android-centric architecture
Activity
Lifecycle	Events
Business	Rules
Access	Hardware
Access	Sensors
Framework	APIs
….
• Mix presentation logic
with business rules
• Code is difficult to
understand
• To rigid to handle
varying use-cases
• Tight coupling & low
cohesion
Activity == View & Controller?
Address book example
Model View Presenter (MVP)
View Presenter Model
The presenter
‣ Make the presenter Framework
independent
‣ The presenter does not depend on
any android specific classes
‣ Abstract the presenter from
implementation details
‣ Abstraction makes it possible to write
non-instrumented tests
Model View Presenter (MVP)
View
<<Activity	/	
Fragment>>
Presenter
<<POJO>>
Model
<<POJO>>
IPresenter
<<Interface>>
IView
<<Interface>>
ViewPresenterContract
<<Interface>>
Model View Presenter (MVP)
View
<<Activity	/	
Fragment>>
Presenter
<<POJO>>
Model
<<POJO>>
IPresenter
<<Interface>>
IView
<<Interface>>
ViewPresenterContract
<<Interface>>
Unit	Tests Unit	TestsInstrumented	Tests
The ViewPresenterContract
The presenter
The view
Unit test
Model View Presenter
Clear separation of UI and
business logic
Separation Modularity
Reuse of presenters and
views
Testing
Testing in isolation without
external dependencies
Model View ViewModel (MVVM)
View ViewModel Model
Observable
/ Databinding
Reference
Model View Intent (MVI)
View Intent Model
State
Actions
Model View Intent (MVI)
Facebook Flux
Action Dispatcher Store
Action
View
MVI Principles
‣ Model that represents the state of the
app
‣ Pure functions
‣ Unidirectional data flow
‣ Immutable data
‣ State reducer takes current state as
input and produces the next state
MVI - Advantages
‣ Separates mutation and
asynchronicity
‣ Makes testing much easier
assertEquals(expectedModel, model)
‣ Readable code
‣ Predictable code
MVI ViewPresenterContract
MVI Presenter
MVI View
MVI Unit test
MVI Instrumentation test
MVI Logging & Timetravel
• { "loading": true, "error": null, "contacts": null }
• { "loading": false, "error": null, "contacts": […] }
• { "loading": true, "error": null, "contacts": null }
• { "loading": false, "error": {NetworkError}, "contacts": null }
Tools
• JUnit
• JaCoCo
• Mockito
• Espresso
• Crashlytics
• Infer
• LeakCanary
KENT BECK
PAUL WEIN
paul.wein@netlight.com
netlight.com

More Related Content

PPT
Testwarez 2009 Use Proper Tool
PPTX
Smart : Comprehensive and unified framework for test automation of web and mo...
PPT
Automated Unit Testing in Silverlight for Windows Phone 7
PPTX
Real Testing Scenario Strategy Practical TestOps Presentation
PPT
SQADAYS 21 Moscow 2017
PDF
Using AI-Powered Visual Tests to empower your tests
PPTX
Building Resilient Automated UI Tests for Cloud Applications using Scripless ...
PPTX
What Can The Spira API Do For You?
Testwarez 2009 Use Proper Tool
Smart : Comprehensive and unified framework for test automation of web and mo...
Automated Unit Testing in Silverlight for Windows Phone 7
Real Testing Scenario Strategy Practical TestOps Presentation
SQADAYS 21 Moscow 2017
Using AI-Powered Visual Tests to empower your tests
Building Resilient Automated UI Tests for Cloud Applications using Scripless ...
What Can The Spira API Do For You?

What's hot (20)

PDF
KeytorcTestTalks #11 - Onur Başkirt, Agile Test Management with Testrail
PDF
What is Agile Testing?
PPTX
17 Ways to Save Time on Manual Cross Browser Testing
PPTX
UI5 supportability tools explained
PPSX
SCM Process and smartBuild
PDF
Testing Design System Changes Across Your Application -- Intuit Use Case -- w...
PPTX
BDD Selenium for Agile Teams - User Stories
PPTX
Kloia Quality Assurance
PPTX
Why we used Feature Branching
PPTX
Meaningful UI Test Automation
PDF
Automated Application Testing
PDF
Test automation - What? Why? How?
PPTX
E2E testing with UIVeri5
PPTX
Mobile Quality Challenges At Zalando
PPTX
Reliable application tests for ui5 apps
PDF
[webinar] Best of Breed: Successful Test Automation Practices from Innovative...
PDF
Optimizing API Documentation: Some Guidelines and Effects
PPT
VodQA3_ATDD_KetanSoni
PPTX
continous integration and delivery
PDF
Software Test Patterns: Successes and Challenges
KeytorcTestTalks #11 - Onur Başkirt, Agile Test Management with Testrail
What is Agile Testing?
17 Ways to Save Time on Manual Cross Browser Testing
UI5 supportability tools explained
SCM Process and smartBuild
Testing Design System Changes Across Your Application -- Intuit Use Case -- w...
BDD Selenium for Agile Teams - User Stories
Kloia Quality Assurance
Why we used Feature Branching
Meaningful UI Test Automation
Automated Application Testing
Test automation - What? Why? How?
E2E testing with UIVeri5
Mobile Quality Challenges At Zalando
Reliable application tests for ui5 apps
[webinar] Best of Breed: Successful Test Automation Practices from Innovative...
Optimizing API Documentation: Some Guidelines and Effects
VodQA3_ATDD_KetanSoni
continous integration and delivery
Software Test Patterns: Successes and Challenges
Ad

Similar to Android-centric-architecture vs. unit testable apps (20)

PDF
How to tdd your mvp
PDF
How to build rock solid apps & keep 100m+ users happy
PDF
Model View Presenter
PDF
Android testing
PDF
Building Maintainable Android Apps (DroidCon NYC 2014)
PPTX
MVVM presentation
PDF
Android meetup
PDF
Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
PPTX
Android DesignArchitectures.pptx
PDF
Refactoring Wunderlist. UA Mobile 2016.
PPTX
MVVM ( Model View ViewModel )
PDF
Mvvm Pattern in Xamarin - MvvmCross and Xamarin.Forms
PDF
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
PDF
Innovation Generation - The Mobile Meetup: Android Best Practices
PDF
MvvmCross Seminar
PDF
MvvmCross Introduction
PDF
Effective Android UI - English
PPSX
Android architecture components
PDF
Cross platform Xamarin Apps With MVVM
PDF
Testable Android Architecture
How to tdd your mvp
How to build rock solid apps & keep 100m+ users happy
Model View Presenter
Android testing
Building Maintainable Android Apps (DroidCon NYC 2014)
MVVM presentation
Android meetup
Droidcon Spain 2016 - The Pragmatic Android Programmer: from hype to reality
Android DesignArchitectures.pptx
Refactoring Wunderlist. UA Mobile 2016.
MVVM ( Model View ViewModel )
Mvvm Pattern in Xamarin - MvvmCross and Xamarin.Forms
Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
Innovation Generation - The Mobile Meetup: Android Best Practices
MvvmCross Seminar
MvvmCross Introduction
Effective Android UI - English
Android architecture components
Cross platform Xamarin Apps With MVVM
Testable Android Architecture
Ad

Recently uploaded (20)

PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
top salesforce developer skills in 2025.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
L1 - Introduction to python Backend.pptx
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPT
Introduction Database Management System for Course Database
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
VVF-Customer-Presentation2025-Ver1.9.pptx
PTS Company Brochure 2025 (1).pdf.......
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Design an Analysis of Algorithms I-SECS-1021-03
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
top salesforce developer skills in 2025.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
L1 - Introduction to python Backend.pptx
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Introduction Database Management System for Course Database
ManageIQ - Sprint 268 Review - Slide Deck
Navsoft: AI-Powered Business Solutions & Custom Software Development
Odoo POS Development Services by CandidRoot Solutions
How to Choose the Right IT Partner for Your Business in Malaysia
Design an Analysis of Algorithms II-SECS-1021-03
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
2025 Textile ERP Trends: SAP, Odoo & Oracle
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...

Android-centric-architecture vs. unit testable apps