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
0
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
GenU導入でCDKに初挑戦し、悪戦苦闘した話
hideg
0
160
長期運用プロダクトの開発速度を維持し続けるためのリファクタリング実践例
wataruss
8
2.7k
Shinjuku.rb#95:心の技術書紹介
free_world21
1
110
LangChainでWebサイトの内容取得やGitHubソースコード取得
shukob
0
160
[DroidKaigi 2024] Android ViewからJetpack Composeへ 〜Jetpack Compose移行のすゝめ〜 / From Android View to Jetpack Compose: A Guide to Migration
syarihu
1
550
What you can do with Ruby on WebAssembly
kateinoigakukun
0
160
Prolog入門
qnighy
4
1k
はじめてみよう量子プログラミング
itokoichi01
0
170
エンジニア1年目で複雑なコードの改善に取り組んだ話
mtnmr
3
2k
LangGraphでのHuman-in-the-Loopの実装
os1ma
3
1.1k
あなたのアプリ、ログはでてますか?あるいはログをだしてますか? (Funabashi.dev用 軽量版)
uzulla
2
120
エラーレスポンス設計から考える、0→1開発におけるGraphQLへの向き合い方
bicstone
5
1.5k
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
304
110k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Adopting Sorbet at Scale
ufuk
73
8.9k
Build your cross-platform service in a week with App Engine
jlugia
228
18k
Git: the NoSQL Database
bkeepers
PRO
425
64k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.3k
The Cost Of JavaScript in 2023
addyosmani
42
5.6k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
227
52k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
26
1.9k
Building Your Own Lightsaber
phodgson
101
6k
Designing the Hi-DPI Web
ddemaree
278
34k
Creatively Recalculating Your Daily Design Routine
revolveconf
215
12k
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?