doc / ch.tutteli.atrium.creating / ThrowableFluent / toThrow

toThrow

inline fun <reified TExpected : Throwable> toThrow(): IAssertionPlant<TExpected> (source)

Makes an assertion about the commonFields's subject that it is of the expected type TExpected and reports an error if subject is null or another type than the expected one.

Exceptions

AssertionError - Might throw an AssertionError if the assertion fails.

IllegalStateException - In case reporting a failure does not throw itself.

Return
This builder to support a fluent-style API.

fun <TExpected : Throwable> toThrow(expectedType: KClass<TExpected>): IAssertionPlant<TExpected> (source)

Use the overload with reified type parameter whenever possible.

Makes an assertion about the commonFields's subject that it is of the expected type TExpected and reports an error if subject is null or another type than the expected one.

Parameters

expectedType - The expected type of the thrown Throwable.

Exceptions

AssertionError - Might throw an AssertionError if the assertion fails.

IllegalStateException - In case reporting a failure does not throw itself.

Return
This builder to support a fluent-style API.

inline fun <reified TExpected : Throwable> toThrow(noinline createAssertions: IAssertionPlant<TExpected>.() -> Unit): IAssertionPlant<TExpected> (source)

Makes an assertion about the commonFields's subject that it is of the expected type TExpected and reports an error if subject is null or another type than the expected one -- furthermore it createAssertions which are checked additionally as well.

Parameters

expectedType - The expected type of the thrown Throwable.

Exceptions

AssertionError - Might throw an AssertionError if an assertion fails.

IllegalStateException - In case reporting a failure does not throw itself.

Return
This builder to support a fluent-style API.

fun <TExpected : Throwable> toThrow(expectedType: KClass<TExpected>, createAssertions: IAssertionPlant<TExpected>.() -> Unit): IAssertionPlant<TExpected> (source)

Use the overload with reified type parameter whenever possible.

Makes an assertion about the commonFields's subject that it is of the expected type TExpected and reports an error if subject is null or another type than the expected one -- furthermore it createAssertions which are checked additionally as well.

Exceptions

AssertionError - Might throw an AssertionError if an assertion fails.

IllegalStateException - In case reporting a failure does not throw itself.

Return
This builder to support a fluent-style API.