toThrow
inline fun Expect.Companion.toThrow(crossinline block: () -> Unit)(source)(source)
Asserts that the given block throws an exception.
If the block completes without throwing an exception, the assertion fails with a message indicating that no exception was thrown. Any exception thrown by the block causes the assertion to pass.
Context Parameters
The assertion scope that will consume the assertion result.
Parameters
The code block that should throw an exception. Called exactly once.
inline fun <ThrowableType : Throwable> Expect.Companion.toThrow(crossinline block: () -> Unit)(source)(source)
Asserts that the given block throws an exception of the specified type ThrowableType.
If the block completes without throwing an exception, the assertion fails with a message indicating that no exception was thrown. If the block throws an exception of the wrong type, the assertion fails with a message indicating the type mismatch.
Context Parameters
The assertion scope that will consume the assertion result.
Parameters
The code block that should throw an exception of type ThrowableType. Called exactly once.
Type Parameters
The expected type of the exception. The exception must be an instance of this type.
inline fun Expect.Companion.toThrow(crossinline block: () -> Unit, checker: Expect<Throwable>.() -> Unit)(source)
Asserts that the given block throws an exception, and if it does, asserts on the thrown exception using the provided checker.
If the block completes without throwing an exception, the assertion fails with a message indicating that no exception was thrown. If the block throws an exception, it is passed to the checker for further assertions.
Context Parameters
The assertion scope that will consume the assertion result.
Parameters
The code block that should throw an exception. Called exactly once.
The assertion block to execute on the thrown exception.
inline fun <ThrowableType : Throwable> Expect.Companion.toThrow(crossinline block: () -> Unit, checker: Expect<ThrowableType>.() -> Unit)(source)
Asserts that the given block throws an exception of the specified type ThrowableType, and if it does, asserts on the thrown exception using the provided checker.
If the block completes without throwing an exception, the assertion fails with a message indicating that no exception was thrown. If the block throws an exception of the wrong type, the assertion fails with a message indicating the type mismatch. If the block throws an exception of the correct type, it is passed to the checker for further assertions.
Context Parameters
The assertion scope that will consume the assertion result.
Parameters
The code block that should throw an exception of type ThrowableType. Called exactly once.
The assertion block to execute on the thrown exception if it is of the expected type.
Type Parameters
The expected type of the exception. The exception must be an instance of this type.