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
mockito-kotlin
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Keisuke Kobayashi
December 15, 2017
Programming
540
1
Share
mockito-kotlin
Android Test Night #2
Keisuke Kobayashi
December 15, 2017
More Decks by Keisuke Kobayashi
See All by Keisuke Kobayashi
プロダクト開発をAI 1stに変革する〜SaaS is dead時代で生き残るために〜 / AI 1st Product Development
kobakei
0
2.4k
今日から始める依存性の注入 / First Time Dependency Injection
kobakei
26
7.7k
iOSアプリの技術的負債をどう返済したか / How to repay the technical debt of iOS app
kobakei
2
1k
iOSアプリ内で不正なSSL証明書を検知する / SSL Pinning for iOS apps
kobakei
34
12k
Kyashアプリ開発の現場
kobakei
4
2.9k
Review of Google I/O 2017 & Prepare for Google I/O 2018
kobakei
0
340
APIクライアントをCodableで置き換えた話
kobakei
0
1.6k
開発者が知っておきたい通知の歴史
kobakei
9
7.8k
2017年に新規アプリを立ち上げた話
kobakei
2
1.1k
Other Decks in Programming
See All in Programming
Smarter Angular mit Transformers.js & Prompt API
christianliebel
PRO
1
120
感情を設計する
ichimichi
5
730
PHP でエミュレータを自作して Ubuntu を動かそう
m3m0r7
PRO
2
170
見せてもらおうか、 OpenSearchの性能とやらを!
shunta27
1
170
安いハードウェアでVulkan
fadis
1
890
夢の無限スパゲッティ製造機 -実装篇- #phpstudy
o0h
PRO
0
190
Claude Codeログ基盤の構築
giginet
PRO
7
3.9k
事業会社でのセキュリティ長期インターンについて
masachikaura
0
230
RSAが破られる前に知っておきたい 耐量子計算機暗号(PQC)入門 / Intro to PQC: Preparing for the Post-RSA Era
mackey0225
3
120
Symfonyの特性(設計思想)を手軽に活かす特性(trait)
ickx
0
120
Kubernetes上でAgentを動かすための最新動向と押さえるべき概念まとめ
sotamaki0421
2
390
Go_College_最終発表資料__外部公開用_.pdf
xe_pc23
0
120
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
310
Rails Girls Zürich Keynote
gr2m
96
14k
Believing is Seeing
oripsolob
1
100
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
750
How GitHub (no longer) Works
holman
316
150k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.4k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.4k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
230
SEO for Brand Visibility & Recognition
aleyda
0
4.4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Transcript
mockito-kotlin Keisuke Kobayashi Android Test Night #2
About Me • Keisuke Kobayashi • GitHub, QIita: kobakei •
Twitter: kobakei122 • Kyash, Inc • ݸਓࣄۀओ
mockito-kotlin͍͍ͧ
mockito-kotlin • KotlinͰMockitoΛ͏ͨΊͷϥΠϒϥϦ • https://github.com/nhaarman/mockito-kotlin • ˒800 over
Ͳ͕͍͍͔͜ • ϞοΫ͕ݟ͘͢ͳΔ • Null҆શରԠ • άϩʔόϧؔͷՃ • whenରԠ
Mockito in Java // Java import static org.mockito.Mockito.*; Hoge mock
= mock(Hoge.class); when(mock.sayHello()).thenReturn("Hello"); when(mock.sayBye()).thenReturn("Bye");
Convert to Kotlin // Kotlin import org.mockito.Mockito.* val mock =
mock(Hoge::class.java) `when`(mock.sayHello()).thenReturn("Hello") `when`(mock.sayBye()).thenReturn("Bye")
mockito-kotlin // Kotlin import com.nhaarman.mockito_kotlin.* val mock = mock<Hoge> {
on { sayHello() } doReturn "Hello" on { sayBye() } doReturn "Bye" }
ݟ͍͢
Null҆શରԠ • Null҆શͷ͍ͤͰɺMockitoͷanyͰNPE • NonNullͳҾʹanyΛ͢ͱൃੜ • anyͱanyOrNull
άϩʔόϧؔ • any, anyOrNull • atLeast, only, never • verify
• whenever
when • Mockitoͷwhenϝιου • Kotlinͷwhen༧ޠ • `when`ͱॻ͔͘͠ແ͍ • mockito-kotlinͰΘΓʹwheneveron͕ ͑Δ
mockito-kotlin͍͍ͧ
Thanks!