notToThrow

context(assertionScope: AssertionScope)
inline fun Expect.Companion.notToThrow(crossinline block: () -> Unit)(source)

Asserts that the given block does not throw any exception.

If the block throws an exception, the assertion fails with a message indicating that an exception was thrown, and the exception is included as the cause.

Context Parameters

assertionScope

The assertion scope that will consume the assertion result.

Parameters

block

The code block that should not throw an exception. Called exactly once.


context(assertionScope: AssertionScope)
inline fun <Result> Expect.Companion.notToThrow(crossinline block: () -> Result, checker: Expect<Result>.() -> Unit)(source)

Asserts that the given block does not throw any exception, and if it succeeds, asserts on the result using the provided checker.

If the block throws an exception, the assertion fails immediately with a message indicating that an exception was thrown. If the block succeeds, the result is passed to the checker for further assertions.

Context Parameters

assertionScope

The assertion scope that will consume the assertion result.

Parameters

block

The code block that should not throw an exception. Called exactly once.

checker

The assertion block to execute on the result if no exception is thrown.

Type Parameters

Result

The type of the result produced by the block.