Slide 15
Slide 15 text
Data Drivenで境界値を並べる
withData(
nameFn = { "${it.name}:保存後${it.expectedTotal}人" },
CapacityCase("空き5席なら予約を作る", 0, ReserveResult("RESERVED"), 1),
CapacityCase("空き1席なら予約を作る", 4, ReserveResult("RESERVED"), 5),
CapacityCase("満席なら予約を増やさない", 5, ReserveResult("EVENT_FULL"), 5),
) { case ->
val (client, koin) = env()
val fixtures = Fixtures(koin.get())
val event = fixtures.event(5, case.reserved)
login.mockLogin(UUID.randomUUID())
val result = client.reserve(event.id)
result["errors"] shouldBe null
val actual = json.treeToValue(
result["data"]["reserve"], ReserveResult::class.java)
assertSoftly {
actual.code shouldBe case.expected.code
fixtures.count(event.id) shouldBe case.expectedTotal
}
}
expected: ReserveResult/expectedTotal: Int。codeと件数を比較し、生成IDは別の成功ケースで確認
15