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

FeatureExtractor

interface FeatureExtractor (source)

Defines the contract for sophisticated safe feature extractions including assertion creation for the feature.

It is similar to FeatureAssertions but differs in the intended usage. FeatureAssertions are intended to make assertions about a return value of a method call or a property, assuming that the call as such always succeeds (no exception is thrown). The FeatureExtractor on the other hand should be used if it is already known, that the call/access fails depending on given arguments. For instance, List.get is a good example where it fails if the given index is out of bounds.

Functions

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>

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

Inheritors

DefaultFeatureExtractor

class DefaultFeatureExtractor : FeatureExtractor