Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
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
0
65
Clean Android Code for Unit Testing
GDG Kaohsiung 2016/07/03
York Wu
July 03, 2016
Tweet
Share
More Decks by York Wu
See All by York Wu
Parcerler
yorkwu0318
0
75
Other Decks in Programming
See All in Programming
AIによる高速開発をどう制御するか? ガードレール設置で開発速度と品質を両立させたチームの事例
tonkotsuboy_com
7
2.2k
カスタマーサクセス業務を変革したヘルススコアの実現と学び
_hummer0724
0
680
Patterns of Patterns
denyspoltorak
0
1.4k
CSC307 Lecture 06
javiergs
PRO
0
680
dchart: charts from deck markup
ajstarks
3
990
Honoを使ったリモートMCPサーバでAIツールとの連携を加速させる!
tosuri13
1
180
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
130
15年続くIoTサービスのSREエンジニアが挑む分散トレーシング導入
melonps
2
190
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
2.5k
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
200
IFSによる形状設計/デモシーンの魅力 @ 慶應大学SFC
gam0022
1
300
責任感のあるCloudWatchアラームを設計しよう
akihisaikeda
3
170
Featured
See All Featured
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
410
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
0
110
How to Ace a Technical Interview
jacobian
281
24k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Become a Pro
speakerdeck
PRO
31
5.8k
Deep Space Network (abreviated)
tonyrice
0
47
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
240
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.2k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
KATA
mclloyd
PRO
34
15k
From π to Pie charts
rasagy
0
120
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
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