$30 off During Our Annual Pro Sale. View Details »

KotlinTest with Spring Boot

KotlinTest with Spring Boot

2019年1月21日 「集まれKotlin好き!Kotlin愛好会 vol7」の談義資料です。

Takehata Naoto

January 21, 2019
Tweet

More Decks by Takehata Naoto

Other Decks in Programming

Transcript

  1.    • Kotlin • Spring Boot • MyBatis

    • KotlinTest • Gradle • gRPC
  2.    • Kotlin • Spring Boot • MyBatis

    • KotlinTest • Gradle • gRPC
  3. ( class SampleServiceForStringSpecTest : StringSpec() { init { val service

    = SampleService() "execute param 1 one " { service.execute(1) shouldBe "one" } •     • shouldBe KotlinTest 
  4. ( class SampleServiceForBehaviorSpecTest : BehaviorSpec() { init { val service

    = SampleService() given("execute") { `when`("param1 ") { val result = service.execute(1) then("one ") { result.shouldBe("one") }
  5. ( class SampleServiceForAnnotationSpecTest : AnnotationSpec() { val service = SampleService()

    @Test fun param1one() { service.execute(1) shouldBe "one" }
  6.    class SampleServiceTest: StringSpec() { init { forall(

    row(10, ""), row(100, "") ) { num, descrip8on -> "execute param ${descrip8on}   " { val service = SampleService() service.execute(num) shouldBe true } } } }
  7.  class SampleServiceForStringSpecTest : StringSpec() { init { val service

    = SampleService() "executeparam1one" { service.execute(1) shouldBe "one" } "f:executeparam2two" { service.execute(2) shouldBe "two" } } }    
  8.  class SampleServiceForStringSpecTest : StringSpec() { init { val service

    = SampleService() "executeparam1one" { service.execute(1) shouldBe "one" } "!executeparam2two" { service.execute(2) shouldBe "two" } } } !
  9.   @ContextConfiguration(classes = [TestApplicationContext::class]) class UserServiceImplTest( private val userService:

    UserService ): StringSpec() { init { ”getUserStatushogefuga" { //  } } }
  10.     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   
  11.     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    •      
  12. 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/.
  13.