fun <E : Any> collectAssertionsForExplanation(noSubjectMessage: String, 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.
assertionCreator
- The function which should at least create one assertion.
subject
- The subject which will be used for the AssertionPlant.
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.