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
Unit Testing While Using RxJava 2
Search
Elvis Lin
December 27, 2017
Programming
400
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Unit Testing While Using RxJava 2
Introduce how to write a unit testing while you use RxJava 2 in your program
Elvis Lin
December 27, 2017
More Decks by Elvis Lin
See All by Elvis Lin
Protect Users' Privacy in iOS 14
elvismetaphor
0
70
Dubugging Tips and Tricks for iOS development
elvismetaphor
0
85
Strategies of Facebook LightSpeed project
elvismetaphor
0
130
Background Execution And WorkManager
elvismetaphor
2
570
作為一個跨平台的 Mobile App 開發者,從入門到放棄!?
elvismetaphor
2
600
Dependency Injection for testability of iOS app
elvismetaphor
1
1.5k
Briefly Introduction of Kotlin coroutines
elvismetaphor
1
340
MotionLayout Brief Introduction
elvismetaphor
1
410
Chapter 10. Pattern Matching with Regular Expressions
elvismetaphor
0
84
Other Decks in Programming
See All in Programming
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
330
Performance Optimization With LLMs
xleitix
0
250
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
140
作れるエンジニアから、価値を届けるエンジニアへ
ryunakayama
1
240
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
420
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
120
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
160
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
1.6k
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
370
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
4
3.8k
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
160
小さなアプリを作って公開するまで
onozaty
0
140
Featured
See All Featured
Deep Space Network (abreviated)
tonyrice
0
410
My Coaching Mixtape
mlcsv
0
380
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.6k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
Design in an AI World
tapps
1
390
How STYLIGHT went responsive
nonsquared
100
6.4k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.2k
HDC tutorial
michielstock
2
1k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
520
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Skip the Path - Find Your Career Trail
mkilby
1
290
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Transcript
如何對使⽤用 RxJava 的 程式做 Unit Test Elvis Lin 2017-12-27@Android Taipei
None
如何測試 Asynchronous Behavior 其實我想說的是
(Synchronous) Long Job Model WebClient Server 準備讀資料 資料回傳 被卡住
(Asynchronous) Long Job Model WebClient Server 準備讀資料 資料回傳 繼續執⾏行行 其他⼯工作
同步的單元測試 • doSyncCall(); • readResult(); • assertResult();
非同步的單元測試? • doAsyncCall(); • sleep(aWhile); • readResult(); • assertResult();
非同步的單元測試 — 基本技巧 • Callback • doAsyncCall(callback); • Pooling
非同步的單元測試 — Pooling doAsyncCall(); startTime = Time.now(); while (!responseReceived) {
if (Time.now() - startTime > waitLimit) throw new TestTimeoutException(); sleep (pollingInterval); } readResult(); assertResult();
在 RxJava 實作 Unit Test • 拆解 Observable 跟 Observer
• 使⽤用 TestObserver 與 TestScheduler • 使⽤用 Interface 隔離實作
拆解 Observer 跟 Observable
使⽤用 TestObserver / TestSubscriber • 範例例:https:// gist.github.com/ elvismetaphor/ 2188fd635d8e3308308bd05c59cf 63fa
使⽤用 Interface 隔離實作
重要的事情說三兩兩遍 • 拆解 Observable 跟 Observer • 使⽤用 TestObserver 與
TestScheduler • 使⽤用 Interface 隔離實作
參參考資料 • Asynchronous Behavior http://teddy-chen-tw.blogspot.tw/ 2012/12/3asynchronous-behavior.html • Testing RxJava2 https://www.infoq.com/articles/Testing-
RxJava2 • Testing asynchronous RxJava code using Mockito https://medium.com/@fabioCollini/testing- asynchronous-rxjava-code-using- mockito-8ad831a16877