doc / ch.tutteli.atrium.domain.builders.creating.collectors / AssertionCollectorBuilder / collectOrExplain

collectOrExplain

inline fun <T, A : BaseAssertionPlant<T, A>, C : BaseCollectingAssertionPlant<T, A, C>> collectOrExplain(safeToCollect: Boolean, warningCannotEvaluate: Translatable, noinline subjectProvider: () -> T, noinline collectingPlantFactory: (() -> T) -> C, noinline assertionCreator: C.() -> Unit): AssertionGroup (source)

Overrides AssertionCollector.collectOrExplain


Deprecated: Switch from Assert to Expect and use the other overload; will be removed with 1.0.0

Depending on the given safeToCollect it either AssertionCollector.collects the assertions the given assertionCreator might create or it uses it to create an AssertionGroup with an ExplanatoryAssertionGroupType.

Parameters

safeToCollect - Indicates whether it is safe to use the subjectProvider (means it does not throw a PlantHasNoSubjectException)

warningCannotEvaluate - The Translatable used to explain why the assertions could not be evaluated.

subjectProvider - Provides the subject which is used as BaseCollectingAssertionPlant.subject.

collectingPlantFactory - The factory method which creates the appropriate collecting plant which is suitable for the given assertionCreator.

assertionCreator - A lambda which typically creates a sub AssertionPlant and adds assertions to it. For instance, if you create a feature assertion or a type transformation assertion, you will typically end up creating a sub assertion plant which delegates created Assertions to the BaseCollectingAssertionPlant.