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
65
Dubugging Tips and Tricks for iOS development
elvismetaphor
0
80
Strategies of Facebook LightSpeed project
elvismetaphor
0
130
Background Execution And WorkManager
elvismetaphor
2
550
作為一個跨平台的 Mobile App 開發者,從入門到放棄!?
elvismetaphor
2
580
Dependency Injection for testability of iOS app
elvismetaphor
1
1.5k
Briefly Introduction of Kotlin coroutines
elvismetaphor
1
330
MotionLayout Brief Introduction
elvismetaphor
1
390
Chapter 10. Pattern Matching with Regular Expressions
elvismetaphor
0
82
Other Decks in Programming
See All in Programming
Jetpack Compose Mechanisms
skydoves
2
660
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
360
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
360
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
140
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.1k
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
320
残高管理から台帳サービスへの進化
artoy
0
180
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
130
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
210
dotNET_vulnclicker_intro.pdf
deka_morita
0
130
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
2.1k
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
460
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Large-scale JavaScript Application Architecture
addyosmani
516
110k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
590
Statistics for Hackers
jakevdp
799
230k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Building AI with AI
inesmontani
PRO
1
1.3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
What's in a price? How to price your products and services
michaelherold
247
13k
Navigating Weather and Climate Data
rabernat
0
550
Building Adaptive Systems
keathley
44
3.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