extract

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

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

Return

The newly created Expect for the extracted feature.

Parameters

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 expectations 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.