doc / ch.tutteli.atrium.core / CoreFactoryCommon / newCollectingPlant

newCollectingPlant

abstract fun <T : Any> newCollectingPlant(subjectProvider: () -> T): CollectingAssertionPlant<T>
Deprecated: Switch to Expect instead of Assert, thus use newCollectingAssertionContainer instead; will be removed with 1.0.0

Creates a CollectingAssertionPlant which is intended to be used as receiver object in lambdas to collect created Assertions inside the lambda.

Notice, that the plant might not provide a CollectingAssertionPlant.subject in which case it throws a PlantHasNoSubjectException if subject is accessed. Use newCheckingPlant instead if you want to know whether the assertions hold.

Parameters

subjectProvider - The function which will either provide the subject for this plant or throw an PlantHasNoSubjectException in case it cannot provide it. A CollectingAssertionPlant should evaluate the subjectProvider only once.

Return
The newly created assertion plant.