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
KotlinTest with Spring Boot
Search
Takehata Naoto
January 21, 2019
Programming
3
1.6k
KotlinTest with Spring Boot
2019年1月21日 「集まれKotlin好き!Kotlin愛好会 vol7」の談義資料です。
Takehata Naoto
January 21, 2019
Tweet
Share
More Decks by Takehata Naoto
See All by Takehata Naoto
組織貢献をするフリーランスエンジニアという生き方
n_takehata
2
3.5k
「2024年版 Kotlin サーバーサイドプログラミング実践開発」の補講 〜O/Rマッパー編〜
n_takehata
2
660
2024年版 Kotlin サーバーサイドプログラミング実践開発
n_takehata
7
5.7k
Server-Side目線で見る、Kotlin Festの楽しみ方
n_takehata
0
460
KotlinとCloud Vision APIで領収書の電子帳簿保存法対応をする
n_takehata
1
1.5k
KotlinConf 2023 現地参加レポート
n_takehata
1
350
サーバーサイドKotlinクイズ
n_takehata
0
220
サーバーサイドでのKotlin Coroutines
n_takehata
0
1.2k
KotlessとDynamoDBで自分のツイートを収集するサーバーレスアプリケーションを作る
n_takehata
0
430
Other Decks in Programming
See All in Programming
Feature Flag 自動お掃除のための TypeScript プログラム変換
azrsh
PRO
4
560
ワイがおすすめする新潟の食 / 20250530phpconf-niigata-eve
kasacchiful
0
140
データと事例で振り返るDevin導入の"リアル" / The Realities of Devin Reflected in Data and Case Studies
rkaga
3
3.4k
tsconfigのオプションで変わる型世界
keisukeikeda
1
120
Efficiency and Rock 'n’ Roll (Really!)
hollycummins
0
540
医療系ソフトウェアのAI駆動開発
koukimiura
1
170
バランスを見極めよう!実装の意味を明示するための型定義 TSKaigi 2025 Day2 (5/24)
whatasoda
2
720
DevDay2025-OracleDatabase-kernel-addressing-history
oracle4engineer
PRO
6
1.5k
❄️ tmux-nixの実装を通して学ぶNixOSモジュール
momeemt
1
110
ruby.wasmとWebSocketで遊ぼう!
lnit
0
140
型安全なDrag and Dropの設計を考える
yudppp
5
630
TVer iOSチームの共通認識の作り方 - Findy Job LT iOSアプリ開発の裏側 開発組織が向き合う課題とこれから
techtver
PRO
0
620
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Into the Great Unknown - MozCon
thekraken
38
1.8k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Git: the NoSQL Database
bkeepers
PRO
430
65k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3k
KATA
mclloyd
29
14k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
The Invisible Side of Design
smashingmag
299
50k
Intergalactic Javascript Robots from Outer Space
tanoku
271
27k
The Pragmatic Product Professional
lauravandoore
34
6.6k
The Power of CSS Pseudo Elements
geoffreycrofte
76
5.8k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Transcript
: Twi%er:@n_takehata %)& +,#,!Kotlin +', $*,( +*"11
+
• Kotlin • Spring Boot • MyBatis
• KotlinTest • Gradle • gRPC
• Kotlin • Spring Boot • MyBatis
• KotlinTest • Gradle • gRPC
1 1 2 B 1 1 . 1 4
3
1 1 2 B 1 1 . 1 4
3
• / • : • K : //
. / / / ./ / / ./
testCompile('io.kotlintest:kotlintest-runner-junit5:3.1.7')
• •
•
( class SampleServiceForStringSpecTest : StringSpec() { init { val service
= SampleService() "execute param 1 one " { service.execute(1) shouldBe "one" } • • shouldBe KotlinTest
• FB • ) F FB • ( S
( class SampleServiceForBehaviorSpecTest : BehaviorSpec() { init { val service
= SampleService() given("execute") { `when`("param1 ") { val result = service.execute(1) then("one ") { result.shouldBe("one") }
• D • ( e B • 3 K
)( `
) ((
( class SampleServiceForAnnotationSpecTest : AnnotationSpec() { val service = SampleService()
@Test fun param1one() { service.execute(1) shouldBe "one" }
• KT @ U • J
• ( ) • K1 • K0
1 1 2 B 1 1 . 1 4
3
• •
class SampleServiceTest: StringSpec() { init { forall(
row(10, ""), row(100, "") ) { num, descrip8on -> "execute param ${descrip8on} " { val service = SampleService() service.execute(num) shouldBe true } } } }
• 1 • 1 • 1
class SampleServiceForStringSpecTest : StringSpec() { init { val service
= SampleService() "executeparam1one" { service.execute(1) shouldBe "one" } "f:executeparam2two" { service.execute(2) shouldBe "two" } } }
) (( 1
class SampleServiceForStringSpecTest : StringSpec() { init { val service
= SampleService() "executeparam1one" { service.execute(1) shouldBe "one" } "!executeparam2two" { service.execute(2) shouldBe "two" } } } !
) (( 2
• B • •
1 1 2 B 1 1 . 1 4
3
None
@ContextConfiguration(classes = [TestApplicationContext::class]) class UserServiceImplTest( private val userService:
UserService ): StringSpec() { init { ”getUserStatushogefuga" { // } } }
testCompile("io.kotlintest:kotlintest-extensions-spring:3.1.8")
package io.kotlintest.provided import io.kotlintest.AbstractProjectConfig import io.kotlintest.extensions.ProjectLevelExtension
import io.kotlintest.spring.SpringAutowireConstructorExtension class ProjectConfig : AbstractProjectConfig() { override fun extensions(): List<ProjectLevelExtension> = listOf(SpringAutowireConstructorExtension) } • AbstractProjectConfig • ConstructorInjection
package io.kotlintest.provided import io.kotlintest.AbstractProjectConfig import io.kotlintest.extensions.ProjectLevelExtension
import io.kotlintest.spring.SpringAutowireConstructorExtension class ProjectConfig : AbstractProjectConfig() { override fun extensions(): List<ProjectLevelExtension> = listOf(SpringAutowireConstructorExtension) } • io.kotlintest.provided • ProjectConfig •
1 1 2 B 1 1 . 1 4
3
• # $)" • (%*
• &+'!
B B 8 2 8 2 / 8 2 9:2
0 88 K S T 1 9 - 80 99 2-8 .8 9 2 / 2 0 2 8 2 9:2 0-88 2 1 8 2 / 8 2 / K 9/.K 1 9 - 80 /1 / 02 //: .8 / : : 8 2 / 9/.
201924 Java→Kotlin https://gihyo.jp/magazine/SD/archive/2019/201902