더북(TheBook)

Pesticide DDT로 전환하기

이제 Pesticide를 사용해 첫 번째 테스트를 완료할 수 있다. 인수 테스트를 작성한 방법과 크게 다르지 않지만 몇 가지 미묘한 차이가 있다.

class SeeATodoListDDT : ZettaiDDT(allActions()) {

    val frank by NamedActor(::ToDoListOwner) 
  
    val bob by NamedActor(::ToDoListOwner)
  
    val shoppingListName = "shopping"
    val shoppingItems = listOf("carrots", "apples", "milk")
  
    val gardenListName = "gardening"
    val gardenItems = listOf("fix the fence", "mowing the lawn")
  
    @DDT
    fun `List owners can see their lists`() = ddtScenario {
        setUp { 
            frank.`starts with a list`(shoppingListName, shoppingItems), 
            bob.`starts with a list`(gardenListName, gardenItems)
        }.thenPlay( 
            frank.`can see #listname with #itemnames`(
                                       shoppingListName, shoppingItems), 
            bob.`can see #listname with #itemnames`(
                                       gardenListName, gardenItems)
        )
    }
}
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.