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
How_to_Test_Server-side_Kotlin.pdf
Search
Taro Nagasawa
September 11, 2018
Programming
1
490
How_to_Test_Server-side_Kotlin.pdf
Kotlin Fest 2018 わいわい報告会 (
https://connpass.com/event/100752/
) で発表したスライドです
Taro Nagasawa
September 11, 2018
Tweet
Share
More Decks by Taro Nagasawa
See All by Taro Nagasawa
Android開発者のための Kotlin Multiplatform入門
ntaro
0
640
Kotlin 最新動向2022 #tfcon #techfeed
ntaro
1
2.2k
#Ubie 狂気の認知施策と選考設計
ntaro
13
13k
UbieにおけるサーバサイドKotlin活用事例
ntaro
1
1.1k
KotlinでSpring 完全理解ガイド #jsug
ntaro
6
3.4k
Kotlinでサーバサイドを始めよう!
ntaro
1
970
Androidからサーバーサイドまで!プログラミング言語 Kotlinの魅力 #devboost
ntaro
5
2.7k
Kotlin Contracts #m3kt
ntaro
4
4k
Kotlin Fest 2018 - Opening session
ntaro
0
4.3k
Other Decks in Programming
See All in Programming
The New Developer Workflow: How AI Transforms Ideas into Code
danielsogl
0
120
Embracing Ruby magic
vinistock
2
230
最速Green Tea 🍵 Garbage Collector
kuro_kurorrr
1
120
파급효과: From AI to Android Development
l2hyunwoo
0
160
AIコーディングの本質は“コード“ではなく“構造“だった / The essence of AI coding is not “code” but "structure
seike460
PRO
2
330
Orleans + Sekiban + SignalR でリアルタイムWeb作ってみた
tomohisa
0
240
七輪ライブラリー: Claude AI で作る Next.js アプリ
suneo3476
1
190
ドメイン駆動設計とXPで支える子どもの未来 / Domain-Driven Design and XP Supporting Children's Future
nrslib
0
230
SwiftDataのカスタムデータストアを試してみた
1mash0
0
150
AIコーディングエージェントを 「使いこなす」ための実践知と現在地 in ログラス / How to Use AI Coding Agent in Loglass
rkaga
4
1.3k
By the way Google Cloud Next 2025に行ってみてどうだった
ymd65536
0
130
generative-ai-use-cases(GenU)の推しポイント ~2025年4月版~
hideg
1
390
Featured
See All Featured
Designing Experiences People Love
moore
142
24k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
32
5.6k
We Have a Design System, Now What?
morganepeng
52
7.6k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.7k
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.7k
Bash Introduction
62gerente
613
210k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
It's Worth the Effort
3n
184
28k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.7k
KATA
mclloyd
29
14k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.7k
Transcript
How to Test Server-side Kotlin 2018-09-11 長澤太郎
長澤太郎 • @ngsw_taro • Ubie株式会社 ソフトウェアエンジニア • 日本Kotlinユーザグループ代表
Redesign Medical Care
Kontributer しらじさん JOIN!!!!
お疲れ様でした! https://photos.google.com/share/AF1QipMux-IXIIBpf2Rr_HwWtQu5pICYJlVCS9yzDmdVbEm0Gajya5D9-pS0A__jXksrAg?key=N0dDZ1hWd HNFVTFodHlpN1BiaC1laXpqQXJkN1Z3 より引用
How to Test Server-side Kotlin エムスリー 前原さん、鈴木さん https://photos.google.com/share/AF1QipMux-IXIIBpf2Rr_HwWtQu5pICYJlVCS9yzDmdVbEm0Gajya5D9-pS0A__jXksrAg?key=N0dDZ1hWd HNFVTFodHlpN1BiaC1laXpqQXJkN1Z3 より引用
How to Test Server-side Kotlin 編
UbieではKotlin x SpringでAPI開発してます
テスト関係のフレームワークやライブラリ • JUnit5 - Jupiter • Spring Test - WebTestClient
• AssertJ • MockK • DbSetup-kotlin
JUnit5 class FooTest { @Nested inner class fooMethod { @Test
fun `should throw exception`() { assertThrows<MyException>() { Foo().foo() } } } }
class FooTest { @Nested inner class fooMethod { @Test fun
`should throw exception`() { assertThrows<MyException>() { Foo().foo() } } } } JUnit5
JUnit5 class FooTest { @Nested inner class fooMethod { @Test
fun `should throw exception`() { assertThrows<MyException>() { Foo().foo() } } } }
AssertJ val got = sut.findUser(id) assertThat(got).isNotNull assertThat(got?.name).isEqualTo("ほげ")
AssertJ val got = sut.findUser(id) assertThat(got).isNotNull assertThat(got?.name).isEqualTo("ほげ") Kotlin 1.3 Contractsで実現か!?
MockK interface UserRepository { suspend fun findUser(id: Long): User? }
val userRepo = mockk<UserRepository>() every { userRepo.findUser(1) } returns user
MockK interface UserRepository { suspend fun findUser(id: Long): User? }
val userRepo = mockk<UserRepository>() every { userRepo.findUser(1) } returns user coEvery { userRepo.findUser(1) } returns user
WebTestClient - expectBodyメソッド webTestClient.get() .exchange() .expectBody(MyApiBody::class.java) .isEqualTo<Nothing>(expectedBody) NullPointerException が出る!
WebTestClient - expectBody拡張関数 webTestClient.get() .exchange() .expectBody<MyApiBody>() .isEqualTo<Nothing>(expectedBody) import org.springframework.test.web.reactive.server.expectBody いける!
WebTestClient - expectBody拡張関数 webTestClient.get() .exchange() .expectBody<MyApiBody>() .isEqualTo<Nothing>(expectedBody) import org.springframework.test.web.reactive.server.expectBody いける!
が、サジェストされない
Pluginのバグ(issueあった)
しらじさん修正プルリク!!!神!!!!
リリースされるのは 1.3.20 乞うご期待