Skip to content

Latest commit

 

History

History
50 lines (35 loc) · 670 Bytes

Kotest Assertions.md

File metadata and controls

50 lines (35 loc) · 670 Bytes

https://kotest.io/docs/assertions/assertions.html

Assertions

  • shouldBe
name shouldBe "eunbin"
// == assertThat(name).isEqualTo("eunbin")

Inspectors

  • forExactly
mylist.forExactly(3) {
    it.city shouldBe "Chicago"
}
  • forAtLeast
val xs = listOf("sam", "gareth", "timothy", "muhammad")

xs.forAtLeast(2) {
    it.shouldHaveMinLength(7)
}

Exceptions

  • shouldThrow
shouldThrow {
  // code in here that you expect to throw an IllegalAccessException
}
// == assertThrows { }
  • shouldThrowAny
val exception = shouldThrowAny {
  // test here can throw any type of Throwable!
}