feature
Helper function to create an ExtractorWithCreator
Extracts the property out of the current subject of this
expectation, creates a new Expect for it and returns it so that subsequent calls are based on the feature.
Return
Since
0.12.0
Extracts the value which is returned when calling the method f on the current subject of this
expectation, creates a new Expect for it and returns it so that subsequent calls are based on the feature.
Use feature of(...)
in case the method requires parameters or in case you want to define an expectation-group for it.
Return
The newly created Expect for the return value of calling the method f on the current subject of this
expectation.
Since
0.12.0
Extracts a feature out of the current subject of this
expectation using the given Feature.extractor, creates a new Expect for it and returns it so that subsequent calls are based on the feature.
Use of(K..., ...)
to create a Feature where the first argument is the extractor in form of a KProperty1 or a KFunctionX
and potentially the required arguments for a KFunctionX
where X
1.
Note, Feature will be made invariant once Kotlin 1.4 is out and Atrium depends on it (most likely with 1.0.0)
Return
The newly created Expect for the extracted feature.
Since
0.12.0
Parameters
Use of(K..., ...)
to create a Feature where the first argument is the extractor in form of a KProperty1 or a KFunctionX
and potentially the required arguments for a KFunctionX
where X
1.
Extracts a feature out of the current subject of this
expectation using the given FeatureWithCreator.extractor, creates a new Expect for it, applies an expectation-group based on the given FeatureWithCreator.assertionCreator for the feature and returns the initial Expect with the current subject.
Use of(K..., ...) { ... }
to create a FeatureWithCreator where the first argument is the extractor in form of a KProperty1 or a KFunctionX
, the last an assertionCreator
-lambda and the remaining arguments in-between the required arguments in case of a KFunctionX
where X
1.
Note, FeatureWithCreator will be made invariant once Kotlin 1.4 is out and Atrium depends on it (most likely with 1.0.0)
Return
an Expect for the subject of this
expectation.
Since
0.12.0
Parameters
Use of(K..., ...) { ... }
to create a FeatureWithCreator where the first argument is the extractor in form of a KProperty1 or a KFunctionX
, the last an assertionCreator
-lambda and the remaining arguments in-between the required arguments in case of a KFunctionX
where X
1.
Extracts a feature out of the current subject of this
expectation, based on the given provider, creates a new Expect for it and returns it so that subsequent calls are based on the feature.
Return
The newly created Expect for the extracted feature.
Since
0.12.0
Parameters
Creates a MetaFeature where the subject of this
expectation is available via implicit parameter it
. Usually you use f to create a MetaFeature, e.g. feature { f(it::size) }
Extracts a feature out of the current subject of this
expectation, based on the given MetaFeatureOptionWithCreator creates a new Expect for it, applies an expectation-group based on the given MetaFeatureOptionWithCreator.assertionCreator for the feature and returns the initial Expect with the current subject.
Note that you need to enable the new type inference of Kotlin (or use Kotlin 1.4 and above) in order that Kotlin is able to infer the types. As workaround you can use the overload which expects MetaFeatureOption<T>.(T) -> MetaFeature<R>
and use it
after the call (import from the package workaround). For instance:
// use
import ch.tutteli.atrium.api.infix.en_GB.workaround.it
expect(person) feature { f(it::age) } it { this toEqual 20 }
// instead of (which causes problems with Kotlin < 1.4)
expect(person) feature of({ f(it::age) }) { this toEqual 20 }
Return
an Expect for the subject of this
expectation.
Since
0.12.0
Parameters
Use the function of({ ... }) { ... }
to create the MetaFeatureOptionWithCreator where the first argument is a lambda with a MetaFeatureOption as receiver which has to create a MetaFeature where the subject of this
expectation is available via implicit parameter it
. Usually you use f to create a MetaFeature, e.g. feature of({ f(it::size) }) { it toEqual 3 }