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
Keisuke Kobayashi
December 15, 2017
Programming
1
480
mockito-kotlin
Android Test Night #2
Keisuke Kobayashi
December 15, 2017
Tweet
Share
More Decks by Keisuke Kobayashi
See All by Keisuke Kobayashi
今日から始める依存性の注入 / First Time Dependency Injection
kobakei
26
7k
iOSアプリの技術的負債をどう返済したか / How to repay the technical debt of iOS app
kobakei
2
850
iOSアプリ内で不正なSSL証明書を検知する / SSL Pinning for iOS apps
kobakei
34
10k
Kyashアプリ開発の現場
kobakei
4
2.5k
Review of Google I/O 2017 & Prepare for Google I/O 2018
kobakei
0
290
APIクライアントをCodableで置き換えた話
kobakei
0
1.4k
開発者が知っておきたい通知の歴史
kobakei
10
7.2k
2017年に新規アプリを立ち上げた話
kobakei
2
980
Everything of CI/CD in Kyash Android
kobakei
0
1.5k
Other Decks in Programming
See All in Programming
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
360
ADRを一年運用してみた/adr_after_a_year
hanhan1978
7
2.3k
使ってみよう Azure AI Document Intelligence
kosmosebi
2
290
try! Swift Tokyo 2024 参加報告 / try! Swift Tokyo 2024 Report
hironytic
0
200
コードレビューで学ぶ!Kotlinオブジェクト指向デザインパターン
akkie76
2
200
新宿ダンジョンを可視化してみた
satoshi7190
2
230
Folding Cheat Sheet #3
philipschwarz
PRO
0
120
Site Reliability Engineering for GMO
pyama86
7
1k
検証も兼ねて個人開発でHonoとかと向き合った話
hanetsuki
0
580
単体テストを書かない技術 #phpcon_odawara
o0h
PRO
26
8.2k
雑に思考を整理する技術と効能
konifar
58
29k
ゆるい個人開発のススメ
kuroppe1819
10
980
Featured
See All Featured
Six Lessons from altMBA
skipperchong
21
3k
Clear Off the Table
cherdarchuk
84
310k
From Idea to $5000 a Month in 5 Months
shpigford
377
45k
Building Adaptive Systems
keathley
31
1.9k
What's in a price? How to price your products and services
michaelherold
237
11k
Making Projects Easy
brettharned
108
5.5k
Automating Front-end Workflow
addyosmani
1356
200k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
20
1.9k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
187
16k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
125
32k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
659
120k
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!