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
160
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
DROBEの生成AI活用事例 with AWS
ippey
0
140
Spring gRPC について / About Spring gRPC
mackey0225
0
230
GAEログのコスト削減
mot_techtalk
0
120
How mixi2 Uses TiDB for SNS Scalability and Performance
kanmo
40
15k
データの整合性を保つ非同期処理アーキテクチャパターン / Async Architecture Patterns
mokuo
53
18k
Bedrock Agentsレスポンス解析によるAgentのOps
licux
3
880
さいきょうのレイヤードアーキテクチャについて考えてみた
yahiru
3
760
JavaScriptツール群「UnJS」を5分で一気に駆け巡る!
k1tikurisu
9
1.8k
バッチを作らなきゃとなったときに考えること
irof
1
430
Ruby on cygwin 2025-02
fd0
0
150
時計仕掛けのCompose
mkeeda
1
310
dbt Pythonモデルで実現するSnowflake活用術
trsnium
0
220
Featured
See All Featured
4 Signs Your Business is Dying
shpigford
182
22k
Fireside Chat
paigeccino
34
3.2k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
193
16k
Thoughts on Productivity
jonyablonski
69
4.5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
Become a Pro
speakerdeck
PRO
26
5.1k
Optimising Largest Contentful Paint
csswizardry
34
3.1k
A Tale of Four Properties
chriscoyier
158
23k
The Cult of Friendly URLs
andyhume
78
6.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.5k
Facilitating Awesome Meetings
lara
52
6.2k
Navigating Team Friction
lara
183
15k
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?