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
430
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
370
Kotlin 最新動向2022 #tfcon #techfeed
ntaro
1
2.1k
#Ubie 狂気の認知施策と選考設計
ntaro
13
12k
UbieにおけるサーバサイドKotlin活用事例
ntaro
1
1.1k
KotlinでSpring 完全理解ガイド #jsug
ntaro
6
3.3k
Kotlinでサーバサイドを始めよう!
ntaro
1
920
Androidからサーバーサイドまで!プログラミング言語 Kotlinの魅力 #devboost
ntaro
5
2.6k
Kotlin Contracts #m3kt
ntaro
4
3.8k
Kotlin Fest 2018 - Opening session
ntaro
0
4.2k
Other Decks in Programming
See All in Programming
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
610
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
110
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
970
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
300
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
140
Jakarta EE meets AI
ivargrimstad
0
130
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
930
flutterkaigi_2024.pdf
kyoheig3
0
150
Featured
See All Featured
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Building Your Own Lightsaber
phodgson
103
6.1k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Code Review Best Practice
trishagee
64
17k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
Fireside Chat
paigeccino
34
3k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
A better future with KSS
kneath
238
17k
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 乞うご期待