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
69
Dubugging Tips and Tricks for iOS development
elvismetaphor
0
81
Strategies of Facebook LightSpeed project
elvismetaphor
0
130
Background Execution And WorkManager
elvismetaphor
2
560
作為一個跨平台的 Mobile App 開發者,從入門到放棄!?
elvismetaphor
2
590
Dependency Injection for testability of iOS app
elvismetaphor
1
1.5k
Briefly Introduction of Kotlin coroutines
elvismetaphor
1
340
MotionLayout Brief Introduction
elvismetaphor
1
400
Chapter 10. Pattern Matching with Regular Expressions
elvismetaphor
0
83
Other Decks in Programming
See All in Programming
phperだってパンチカードでコーディングしたい
o0h
PRO
0
350
Domain-Driven Transformation
hschwentner
2
2.3k
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
800
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
180
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
700
AWSに止められる覚悟してますか?
morizo_1984
2
540
sbt 2.0: takeoff
eed3si9n
0
160
【加筆修正版】Laravel のアプリケーションをどこにデプロイするか #phpcon_ehime
akase244
0
150
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
120
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
610
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
28
33k
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
300
Amusing Abliteration
ianozsvald
1
350
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
The Mindset for Success: Future Career Progression
greggifford
PRO
0
540
Site-Speed That Sticks
csswizardry
13
1.6k
It's Worth the Effort
3n
188
29k
Thoughts on Productivity
jonyablonski
76
5.4k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Claude Code のすすめ
schroneko
67
230k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.9k
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