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
Unit Testing / Understanding Rx Java
Search
Trevor John
November 10, 2015
Programming
180
1
Share
Unit Testing / Understanding Rx Java
Talk on understanding RxJava interfaces given at the NY Android meetup on 11/10/2015
Trevor John
November 10, 2015
Other Decks in Programming
See All in Programming
AI-DLC Deep Dive
yuukiyo
9
5.3k
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
950
How Swift's Type System Guides AI Agents
koher
0
320
From Formal Specification to Property Based Test
ohbarye
0
640
CDK Deployのための ”反響定位”
watany
5
920
의존성 주입과 모듈화
fornewid
0
160
tRPCの概要と少しだけパフォーマンス
misoton665
2
250
リセットCSSを1行消したらアクセシビリティが向上した話
pvcresin
4
420
セグメントとターゲットを意識するプロポーザルの書き方 〜採択の鍵は、誰に刺すかを見極めるマーケティング戦略にある〜
m3m0r7
PRO
0
720
KMP × Kotlin 2.3 - How Android Got Slower While iOS Builds Improved by 47%
rio432
0
100
Kingdom of the Machine
yui_knk
2
1.3k
Road to RubyKaigi: Play Hard(ware)
makicamel
1
520
Featured
See All Featured
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
500
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2.9k
The Pragmatic Product Professional
lauravandoore
37
7.2k
How to make the Groovebox
asonas
2
2.1k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.2k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
199
73k
Rails Girls Zürich Keynote
gr2m
96
14k
Tell your own story through comics
letsgokoyo
1
910
Automating Front-end Workflow
addyosmani
1370
200k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
220
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
Transcript
Unit Testing Rx API’s (Understanding Rx API’s) Trevor John Draft
trevorrjohn @trevorrjohn
What We Will Cover Learn how RxJava APIs work (should
work) How to use what we learned to write simple tests
Quick Overview Rx programming definition: An API for asynchronous programming
with observable streams (http: //reactivex.io/) While the API is simple it is very large Most common use case is fetching data
RxJava Usage Allows you to simply handle responses while ignoring
threading It allows for easier error handling Minimizes race conditions
Understanding How Rx Works Observable
Understanding How Rx Works Observable
Understanding How Rx Works Observable
Understanding How Rx Works Subscription
Understanding How Rx Works With Rx if nobody is listening
it won’t do anything! No subscription, no anything (There are exceptions)
Unit Test It Unit test → Mock it!
WHOA!? Crazy right?! Not flexible Not practical What can we
do? What if we want to use map?
WHOA!? The test doesn’t even work… :(
Observable Creation OnSubscribe interface? Subscriber?
Subscriber! I know those methods! Observable#subscribe() How data is passed
back How does this help us test?
So what now?
Fake OnSubscribe Captures the subscriber Creates interface for notifying the
subscriber
How Do We Use It? That looks good! Not tied
to the implementation!
What is Better? 5* statements Reusable Magic? 11 statements Ridged
Very straightforward
Another Option? Subjects! - They are super powerful and could
be a better/simpler solution for testing. Less configurable, but it works and no “fake” classes
Common Smells Name your tests! @Test public void methodName_context_assertion() Keep
tests short! Limit assertions per test
Questions?