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

collectAssertionsForExplanation

fun <E : Any> collectAssertionsForExplanation(warning: Translatable, assertionCreator: AssertionPlant<E>.() -> Unit, subject: E?): List<Assertion>

Collects the Assertion created by assertionCreator and uses the given subject as CollectingAssertionPlant.subject if not null.

In case subject is null then a 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

warning - The translatable used to explain why the assertions could not be evaluated. assertionCreator - The function which should at least create one assertion. subject - The subject which will be used for the AssertionPlant.

Exceptions

IllegalArgumentException - Might throw an IllegalArgumentException in case the assertionCreator function does not even create one Assertion -- 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.