doc / ch.tutteli.atrium.creating / ThrowableFluent

ThrowableFluent

class ThrowableFluent : IThrowableFluent

Provides toThrow methods for making assertions about a Throwable which one expects was thrown.

The reason why this class does not implement an interface lies in the fact that interfaces cannot have inline functions (at least so far) and we want to provide toThrow with the reified type parameter as first suggestion in Intellij's auto-completion. That is also the reason why we did not define the inline functions as extension functions of IThrowableFluent (in contrast to AtriumFactory where we moved inline functions to IAtriumFactory, for instance, IAtriumFactory.newCheckLazilyAtTheEnd is such a case).

Properties

commonFields

val commonFields: CommonFields<Throwable?>

The commonFields's subject represents the thrown Throwable and will be used in ThrowableFluent.toThrow. Its method IAssertionPlantWithCommonFields.CommonFields.fail could be used for failure reporting etc.

Functions

toThrow

fun <TExpected : Throwable> toThrow(): IAssertionPlant<TExpected>

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.

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

Use the overload with reified type parameter whenever possible.

fun <TExpected : Throwable> toThrow(createAssertions: IAssertionPlant<TExpected>.() -> Unit): IAssertionPlant<TExpected>

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.