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
コミュニティ駆動 AWS CDK ライブラリ「Open Constructs Library」 / community-cdk-library
gotok365
2
230
Better Code Design in PHP
afilina
0
160
SwiftUI Viewの責務分離
elmetal
PRO
2
260
コードを読んで理解するko build
bells17
1
110
Rails アプリ地図考 Flush Cut
makicamel
1
130
Djangoにおける複数ユーザー種別認証の設計アプローチ@DjangoCongress JP 2025
delhi09
PRO
4
460
第3回関東Kaggler会_AtCoderはKaggleの役に立つ
chettub
3
1.1k
バッチを作らなきゃとなったときに考えること
irof
2
500
Django NinjaによるAPI開発の効率化とリプレースの実践
kashewnuts
1
250
GoとPHPのインターフェイスの違い
shimabox
2
210
CloudNativePGを布教したい
nnaka2992
0
110
DROBEの生成AI活用事例 with AWS
ippey
0
140
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
98
5.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
366
25k
4 Signs Your Business is Dying
shpigford
182
22k
A Tale of Four Properties
chriscoyier
158
23k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
120k
Agile that works and the tools we love
rasmusluckow
328
21k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
Typedesign – Prime Four
hannesfritz
40
2.5k
Docker and Python
trallard
44
3.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
Building Applications with DynamoDB
mza
93
6.2k
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?