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
1
1.3k
「2024年版 Kotlin サーバーサイドプログラミング実践開発」の補講 〜O/Rマッパー編〜
n_takehata
2
590
2024年版 Kotlin サーバーサイドプログラミング実践開発
n_takehata
7
5k
Server-Side目線で見る、Kotlin Festの楽しみ方
n_takehata
0
400
KotlinとCloud Vision APIで領収書の電子帳簿保存法対応をする
n_takehata
1
880
KotlinConf 2023 現地参加レポート
n_takehata
1
320
サーバーサイドKotlinクイズ
n_takehata
0
190
サーバーサイドでのKotlin Coroutines
n_takehata
0
1.2k
KotlessとDynamoDBで自分のツイートを収集するサーバーレスアプリケーションを作る
n_takehata
0
400
Other Decks in Programming
See All in Programming
PHPカンファレンス名古屋2025 タスク分解の試行錯誤〜レビュー負荷を下げるために〜
soichi
1
190
GitHub Actions × RAGでコードレビューの検証の結果
sho_000
0
260
昭和の職場からアジャイルの世界へ
kumagoro95
1
380
2024年のWebフロントエンドのふりかえりと2025年
sakito
2
250
2,500万ユーザーを支えるSREチームの6年間のスクラムのカイゼン
honmarkhunt
6
5.3k
Pulsar2 を雰囲気で使ってみよう
anoken
0
240
Introduction to kotlinx.rpc
arawn
0
700
PHPのバージョンアップ時にも役立ったAST
matsuo_atsushi
0
110
Unity Android XR入門
sakutama_11
0
160
コミュニティ駆動 AWS CDK ライブラリ「Open Constructs Library」 / community-cdk-library
gotok365
2
120
プログラミング言語学習のススメ / why-do-i-learn-programming-language
yashi8484
0
130
Domain-Driven Transformation
hschwentner
2
1.9k
Featured
See All Featured
A designer walks into a library…
pauljervisheath
205
24k
Automating Front-end Workflow
addyosmani
1368
200k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
46
2.3k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Done Done
chrislema
182
16k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.1k
Designing for Performance
lara
604
68k
Writing Fast Ruby
sferik
628
61k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
550
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
410
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