Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Clean Android Code for Unit Testing
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
York Wu
July 03, 2016
Programming
65
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Clean Android Code for Unit Testing
GDG Kaohsiung 2016/07/03
York Wu
July 03, 2016
More Decks by York Wu
See All by York Wu
Parcerler
yorkwu0318
0
77
Other Decks in Programming
See All in Programming
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
最近”作らせてる” ローカルAIアプリの話
akit37
0
470
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
golang-bob.pdf
iwatsukayura
0
130
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
590
phperだってパンチカードでコーディングしたい
o0h
PRO
0
330
ChromeでローカルLLM
ryu1013
0
140
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
380
Domain-Driven Transformation
hschwentner
2
2.3k
残高管理から台帳サービスへの進化
artoy
1
200
Featured
See All Featured
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
How to Talk to Developers About Accessibility
jct
2
580
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Color Theory Basics | Prateek | Gurzu
gurzu
1
490
Paper Plane
katiecoart
PRO
5
54k
Building Adaptive Systems
keathley
44
3.2k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
940
A better future with KSS
kneath
240
18k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
330
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Transcript
Clean Android Code for Unit Testing York Wu 2016.07.03
Sample Project https://github.com/yorkwu0318/GDGK_Testing_Sample Unit testing PPT https://goo.gl/sTaFlm CI 環境建置 http://goo.gl/nAAfhF
CI PPT https://goo.gl/dSsMyU
Why Testing?
Testing Type Type Subtype Tool Unit Tests Local Unit Test
Junit Instrumented unit tests JVM
Testing Type Type Subtype Tool Integration Tests Components within your
app only Espresso Cross-app Components UI Automator
Testing Type Other Integration Test Unit Test
Demo 1
How to test it?
Model
Demo 2
None
None
None
None
UI Test!!
None
None
multi-thread
Fix it: register Idling Resource
None
How Testing
Hard to test code 1. Android Framework 2. Async Task
Write Testable Code 1. Dependency Injection 2. Base on MVP
Pattern (Clean Architecture)
Dependency Injection Demo3
None
build.gradle Ref Android Testing Codelab Android Architecture Blueprints
None
None
but unit testing..
we need better architecture • MVC • MVP • MVVM
(Databinding)
MVC C M V logic Activty LoginModel Activty, View
MVC C Activty M LoginModel V Activty, View logic Activity
and logic can’t be divided
MVP P LoginPresenter M LoginModel V Activty, View logic
MVP P LoginPresenter M LoginModel V Activty, View logic
None
None
Demo4 - MVP
None
MVVM VM LoginViewModel M LoginModel V Activty, View logic
Demo4 - MVVM
None
PreseterTest
Optimization • Data Binding • Retrofit 2 • RxJava
Retrofit 2 + RxJava Mock
RxJava mock prod
RxJava
DataBinding 1. remove findViewById( ) 2. remove view.setValue( ) 3.
simply ui logic 4. demo /ex
Testing Strategy • Mock data • Mock library
None
TDD 1. new request 2. add tests 3. red to
green practice: add new request on /ex ex: email/password regular email/password length
Summary 1. testing is used to protect code logic. 2.
testing is not used to test server API result!! 3. testing needs the testable code. 4. testable code needs good-designed code.
Q&A