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
190
1
Share
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
Other Decks in Programming
See All in Programming
Swiftのレキシカルスコープ管理
kntkymt
0
200
Modding RubyKaigi for Myself
yui_knk
0
490
[BalkanRuby 2026] Drop your app/services!
palkan
3
700
Transactional Change Stream Processing With Debezium and Apache Flink
gunnarmorling
1
130
Sans tests, vos agents ne sont pas fiables
nabondance
0
160
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
380
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.1k
今さら聞けないCancellationToken
htkym
0
200
ビジネスモデルから紐解く、AI+型駆動開発
hirokiomote
2
2.9k
Inspired By RubyKaigi (EN)
atzzcokek
0
120
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
7
2.7k
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
0
490
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
135
9.8k
Building Applications with DynamoDB
mza
96
7k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.3k
For a Future-Friendly Web
brad_frost
183
10k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
750
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
180
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
350
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
170
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?