softly

inline fun AssertionScope.softly(block: context(AssertionScope) () -> Unit)(source)

Executes the given assertion block in a "soft" mode, collecting all assertion failures and reporting them together at the end.

In soft assertion mode, individual assertion failures within the block do not immediately throw exceptions. Instead, all failures are collected and reported together as a single assertion failure at the end of the block execution. This is useful when you want to check multiple conditions and see all failures at once, rather than stopping at the first failure.

The failure message includes all individual assertion failures formatted in a tree structure with their messages and stack traces (if available).

Receiver

The assertion scope that will receive the aggregated failure report.

Parameters

block

The assertion block to execute in soft mode. All assertion failures within this block are collected and reported together.


@JvmName(name = "softlyContextual")
context(assertionScope: AssertionScope)
inline fun softly(block: context(AssertionScope) () -> Unit)(source)

Executes the given assertion block in a "soft" mode within the current assertion scope.

This contextual version uses the assertionScope from the surrounding context. In soft assertion mode, individual assertion failures within the block do not immediately throw exceptions. Instead, all failures are collected and reported together as a single assertion failure at the end of the block execution.

Context Parameters

assertionScope

The assertion scope that will receive the aggregated failure report.

Parameters

block

The assertion block to execute in soft mode. All assertion failures within this block are collected and reported together.

See also