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
510
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
760
Kotlin 最新動向2022 #tfcon #techfeed
ntaro
1
2.3k
#Ubie 狂気の認知施策と選考設計
ntaro
13
13k
UbieにおけるサーバサイドKotlin活用事例
ntaro
1
1.1k
KotlinでSpring 完全理解ガイド #jsug
ntaro
6
3.5k
Kotlinでサーバサイドを始めよう!
ntaro
1
1k
Androidからサーバーサイドまで!プログラミング言語 Kotlinの魅力 #devboost
ntaro
5
2.8k
Kotlin Contracts #m3kt
ntaro
4
4.2k
Kotlin Fest 2018 - Opening session
ntaro
0
4.3k
Other Decks in Programming
See All in Programming
FindyにおけるTakumi活用と脆弱性管理のこれから
rvirus0817
0
480
MCPでVibe Working。そして、結局はContext Eng(略)/ Working with Vibe on MCP And Context Eng
rkaga
5
2.2k
AI Coding Agentのセキュリティリスク:PRの自己承認とメルカリの対策
s3h
0
200
Design Foundational Data Engineering Observability
sucitw
3
190
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
110
JSONataを使ってみよう Step Functionsが楽しくなる実践テクニック #devio2025
dafujii
1
510
アプリの "かわいい" を支えるアニメーションツールRiveについて
uetyo
0
220
意外と簡単!?フロントエンドでパスキー認証を実現する WebAuthn
teamlab
PRO
2
720
さようなら Date。 ようこそTemporal! 3年間先行利用して得られた知見の共有
8beeeaaat
3
1.4k
MCPとデザインシステムに立脚したデザインと実装の融合
yukukotani
4
1.4k
請來的 AI Agent 同事們在寫程式時,怎麼用 pytest 去除各種幻想與盲點
keitheis
0
110
Navigation 2 を 3 に移行する(予定)ためにやったこと
yokomii
0
120
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
RailsConf 2023
tenderlove
30
1.2k
A Modern Web Designer's Workflow
chriscoyier
696
190k
Designing for humans not robots
tammielis
253
25k
Being A Developer After 40
akosma
90
590k
GitHub's CSS Performance
jonrohan
1032
460k
The Art of Programming - Codeland 2020
erikaheidi
55
13k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.5k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.8k
Facilitating Awesome Meetings
lara
55
6.5k
Balancing Empowerment & Direction
lara
3
620
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
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 乞うご期待