Quick testing tips #11


Test exceptions with Kotest




import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.spec.style.StringSpec

class Test : StringSpec({
  "it should throw exception" {
    val systemUnderTest = SystemUnderTest()
    shouldThrow {
      systemUnderTest.doStuff()
    }
  }
})



Need to check system under test against exceptions? Use shouldThrow from Kotest assertions package.



Read next:


Loading ...
Failed to load data.