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
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
570
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.2k
そこに3びきプロダクトがいるじゃろう——生成AI時代における“価値が届かない理由”の構造
kosuket
0
580
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
150
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
120
思考垂れ流し開発 ~音声入力 × AIエージェント × 開発ハーネスによる試行錯誤~
npostring
0
180
Discordを用いたラボオートメーション関連情報収集の自動化
noguhiro2002
0
440
異なる設計思想のフレームワークを経験して得た学び
amekuhideki
1
530
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
230
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
550
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
260
AWS Transform Customによる Spring Boot 2.xから4.xへのVerUp
satoshi256kbyte
2
100
Featured
See All Featured
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.5k
Making the Leap to Tech Lead
cromwellryan
135
10k
Crafting Experiences
bethany
1
260
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
Test your architecture with Archunit
thirion
2
2.4k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
45k
It's Worth the Effort
3n
188
29k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
740
Why Our Code Smells
bkeepers
PRO
340
58k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.5k
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?