doc / ch.tutteli.atrium.api.infix.en_GB / withRepresentation

withRepresentation

infix fun <T> RootExpect<T>.withRepresentation(textRepresentation: String): Expect<T>
infix fun <T, R> FeatureExpect<T, R>.withRepresentation(textRepresentation: String): Expect<R>

Wraps the given textRepresentation into a RawString and uses it as representation of the subject instead of the representation that has been defined so far (which defaults to the subject itself).

In case Expect.maybeSubject is not defined i.e. None, then the previous representation is used.

infix fun <T> RootExpect<T>.withRepresentation(representationProvider: (T) -> Any): Expect<T>
infix fun <T, R> FeatureExpect<T, R>.withRepresentation(representationProvider: (R) -> Any): Expect<R>

Uses the given representationProvider to retrieve a representation which can be based on the current subject where it is used as new representation of the subject instead of the representation that has been defined so far (which defaults to the subject itself).

Notice, if you want to use text (e.g. a String) as representation, then wrap it into a RawString via RawString.create and pass the RawString instead. If your text does not include the current subject, then we recommend to use the other overload which expects a String and does the wrapping for you.

In case Expect.maybeSubject is not defined i.e. None, then the previous representation is used.