assertFailsWith

inline fun <reified T : Throwable> assertFailsWith(
    message: String? = null,
    noinline block: () -> Unit
): T
(source)

Asserts that a block fails with a specific exception of type T being thrown. Since inline method doesn't allow to trace where it was invoked, it is required to pass a message to distinguish this method call from others.

fun <T : Throwable> assertFailsWith(
    exceptionClass: KClass<T>,
    block: () -> Unit
): T
(source)
expect fun <T : Throwable> assertFailsWith(
    exceptionClass: KClass<T>,
    message: String?,
    block: () -> Unit
): T
(source)

Asserts that a block fails with a specific exception of type exceptionClass being thrown.