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
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.2k
Quine, Polyglot, 良いコード
qnighy
4
640
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
cmp.Or に感動した
otakakot
3
190
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
620
CSC509 Lecture 11
javiergs
PRO
0
180
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
TypeScript Graph でコードレビューの心理的障壁を乗り越える
ysk8hori
2
1.1k
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
130
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Side Projects
sachag
452
42k
Documentation Writing (for coders)
carmenintech
65
4.4k
Designing the Hi-DPI Web
ddemaree
280
34k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Adopting Sorbet at Scale
ufuk
73
9.1k
Visualization
eitanlees
145
15k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Happy Clients
brianwarren
98
6.7k
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?