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
170
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
#QiitaBash TDDで(自分の)開発がどう変わったか
ryosukedtomita
1
360
QA x AIエコシステム段階構築作戦
osu
0
260
構文解析器入門
ydah
7
2.1k
Nuances on Kubernetes - RubyConf Taiwan 2025
envek
0
140
The State of Fluid (2025)
s2b
0
120
CEDEC 2025 『ゲームにおけるリアルタイム通信への QUIC導入事例の紹介』
segadevtech
3
830
Vibe coding コードレビュー
kinopeee
0
430
Amazon Q CLI開発で学んだAIコーディングツールの使い方
licux
3
180
CLI ツールを Go ライブラリ として再実装する理由 / Why reimplement a CLI tool as a Go library
ktr_0731
3
1k
What's new in Adaptive Android development
fornewid
0
140
Terraform やるなら公式スタイルガイドを読もう 〜重要項目 10選〜
hiyanger
12
3k
ライブ配信サービスの インフラのジレンマ -マルチクラウドに至ったワケ-
mirrativ
1
140
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
KATA
mclloyd
32
14k
Building Applications with DynamoDB
mza
96
6.5k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.4k
Six Lessons from altMBA
skipperchong
28
3.9k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.4k
Being A Developer After 40
akosma
90
590k
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?