doc / ch.tutteli.atrium.creating / AssertionCollector / Collector / collectAssertionsForExplanation

collectAssertionsForExplanation

fun <E : Any> collectAssertionsForExplanation(noSubjectMessage: String, warning: ITranslatable, assertionCreator: IAssertionPlant<E>.() -> Unit, subject: E?): List<IAssertion>

Collects the IAssertion created by assertionCreator and uses the given subject as ICollectingAssertionPlant.subject if not null.

In case subject is null then an PlantHasNoSubjectException is thrown in case the subject is accessed (which does not need to be the case all the time). In such a case a single ExplanatoryAssertionGroup is returned containing a warning.

Parameters

assertionCreator - The function which should at least create one assertion. subject - The subject which will be used for the IAssertionPlant.

Exceptions

IllegalArgumentException - Might throw an IllegalArgumentException in case the assertionCreator function does not even create one IAssertion -- depending on the previously chosen option (see throwIfNoAssertionIsCollected and doNotThrowIfNoAssertionIsCollected).

Return
A list with the collected assertion or an ExplanatoryAssertionGroup with a warning if subject is null and an assertion function tries to access it.