assertFails

Common
JVM
JS
Native
1.0
inline fun assertFails(block: () -> Unit): Throwable
(source)

Asserts that given function block fails by throwing an exception.

Return An exception that was expected to be thrown and was successfully caught. The returned exception can be inspected further, for example by asserting its property values.

Common
JVM
JS
Native
1.1
inline fun assertFails(
    message: String?,
    block: () -> Unit
): Throwable

(source)

Asserts that given function block fails by throwing an exception.

If the assertion fails, the specified message is used unless it is null as a prefix for the failure message.

Return An exception that was expected to be thrown and was successfully caught. The returned exception can be inspected further, for example by asserting its property values.