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
500
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
660
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
4.1k
Kotlin Fest 2018 - Opening session
ntaro
0
4.3k
Other Decks in Programming
See All in Programming
Investigating Multithreaded PostgreSQL
macdice
0
150
Reactive Thinking with Signals, Resource API, and httpResource @Devm.io Angular 20 Launch Party
manfredsteyer
PRO
0
130
複数アプリケーションを育てていくための共通化戦略
irof
0
330
コードに語らせよう――自己ドキュメント化が内包する楽しさについて / Let the Code Speak
nrslib
5
1k
REST API設計の実践 – ベストプラクティスとその落とし穴
kentaroutakeda
2
320
UPDATEがシステムを複雑にする? イミュータブルデータモデルのすすめ
shimomura
0
190
#QiitaBash TDDでAIに設計イメージを伝える
ryosukedtomita
2
1.6k
衛星の軌道をWeb地図上に表示する
sankichi92
0
250
TypeScript を活かしてデザインシステム MCP を作る / #tskaigi_after_night
izumin5210
4
480
"使いづらい" をリバースエンジニアリングする UI の読み解き方
rebase_engineering
0
110
MLOps Japan 勉強会 #52 - 特徴量を言語を越えて一貫して管理する, 『特徴量ドリブン』な MLOps の実現への試み
taniiicom
2
570
Rails産でないDBを Railsに引っ越すHACK - Omotesando.rb #110
lnit
1
100
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
357
30k
The Cost Of JavaScript in 2023
addyosmani
49
8.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
840
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.4k
Balancing Empowerment & Direction
lara
1
84
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
32
5.8k
Build The Right Thing And Hit Your Dates
maggiecrowley
35
2.7k
Writing Fast Ruby
sferik
628
61k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
620
Code Reviewing Like a Champion
maltzj
523
40k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
1
79
Embracing the Ebb and Flow
colly
85
4.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 乞うご期待