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

toThrow

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

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.

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

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.