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
1
180
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
Tweet
Share
Other Decks in Programming
See All in Programming
Event Storming
hschwentner
3
1.3k
TipKitTips
ktcryomm
0
130
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
120
AI活用のコスパを最大化する方法
ochtum
0
120
Raku Raku Notion 20260128
hareyakayuruyaka
0
430
クライアントワークでSREをするということ。あるいは事業会社におけるSREと同じこと・違うこと
nnaka2992
1
250
CSC307 Lecture 12
javiergs
PRO
0
450
CSC307 Lecture 14
javiergs
PRO
0
440
Claude Code、ちょっとした工夫で開発体験が変わる
tigertora7571
0
190
Beyond the Basics: Signal Forms
manfredsteyer
PRO
0
110
AI巻き込み型コードレビューのススメ
nealle
2
2.4k
grapheme_strrev関数が採択されました(あと雑感)
youkidearitai
PRO
1
190
Featured
See All Featured
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
250
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
480
Amusing Abliteration
ianozsvald
0
120
Thoughts on Productivity
jonyablonski
75
5.1k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
210
A designer walks into a library…
pauljervisheath
210
24k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
190
The Curious Case for Waylosing
cassininazir
0
260
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
220
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.8k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
80
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?