doc / ch.tutteli.atrium.logic.creating.transformers / FeatureExtractor / extract


abstract fun <T, R> extract(container: AssertionContainer<T>, description: Translatable, representationForFailure: Any, featureExtraction: (T) -> Option<R>, maybeSubAssertions: Option<Expect<R>.() -> Unit>, featureExpectOptions: FeatureExpectOptions<R>): FeatureExpect<T, R> (source)

Extracts a feature according to the given featureExtraction, creates an Expect for the new subject and applies maybeSubAssertions in case they are specified.


container - the container with the current subject (before the change)

description - Describes the feature

representationForFailure - Representation in case the extraction cannot be carried out.

featureExtraction - Extracts the feature where it returns the feature wrapped into a Some if the extraction as such can be carried out, otherwise None.

maybeSubAssertions - Optionally, subsequent assertions for the feature (the new subject). This is especially useful if the extraction cannot be carried out, because this way we can then already show to you (in error reporting) what you wanted to assert about the feature (which gives you more context to the error).

featureExpectOptions - Additional options which shall apply to the feature extraction.

The newly created Expect for the extracted feature.