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
370
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
Kotlin 最新動向2022 #tfcon #techfeed
ntaro
1
2k
#Ubie 狂気の認知施策と選考設計
ntaro
13
12k
UbieにおけるサーバサイドKotlin活用事例
ntaro
1
1k
KotlinでSpring 完全理解ガイド #jsug
ntaro
6
3.1k
Kotlinでサーバサイドを始めよう!
ntaro
1
830
Androidからサーバーサイドまで!プログラミング言語 Kotlinの魅力 #devboost
ntaro
5
2.3k
Kotlin Contracts #m3kt
ntaro
4
3.4k
Kotlin Fest 2018 - Opening session
ntaro
0
4.2k
Spring Fu on GraalVM
ntaro
0
2.1k
Other Decks in Programming
See All in Programming
架空のコンペ_スクワットフォーム判別コンペの解法
cpptake
0
430
PHPカンファレンス関西2024でLTとスタッフした
ohmori_yusuke
2
120
25 Years of the JCP Program
ivargrimstad
0
1k
「Hono遍歴」と「HonoXでブログ作成」
yasu551
0
170
Running Laravel Apps With FrankenPHP
dunglas
4
1.2k
導入から5年が経って見えた Datadog APM 運用の課題
bgpat
1
480
UnityプログラミングバイブルR6号宣伝&Unity Logging小話
adarapata
0
110
TerraformをやめてCDKでReStartしたあと、 CDKをやめてCDK for TerraformでReStartした話
tmiura0203
0
770
Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
860
LPIXEL×CADDi_kaerururu
kaerururu
3
270
ここ1~2年くらいで 使えるようになった(主要ブラウザーの最新版 がすべて対応した ) ウェブの新機能について ランダムに喋る!
myzkyy
7
5.9k
オープンなデータ・ソフトウェアを活用した開発
404background
0
160
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
35
2.4k
What's new in Ruby 2.0
geeforr
335
31k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
24
2.2k
Learning to Love Humans: Emotional Interface Design
aarron
266
39k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
56
13k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
6
930
The Straight Up "How To Draw Better" Workshop
denniskardys
227
130k
Why Our Code Smells
bkeepers
PRO
330
56k
Making the Leap to Tech Lead
cromwellryan
122
8.4k
Designing for humans not robots
tammielis
247
25k
Raft: Consensus for Rubyists
vanstee
130
6.2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3k
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 乞うご期待