prop

fun <T, P> Assert<T>.prop(name: String, extract: (T) -> P): Assert<P>

Returns an assert that asserts on the given property of the value.

Parameters

name

The name of the property to show in failure messages.

extract

The function to extract the property value out of the value of the current assert.

assertThat(person).prop("name", { it.name }).isEqualTo("Sue")

fun <T, P> Assert<T>.prop(property: KProperty1<T, P>): Assert<P>

Returns an assert that asserts on the given property.

Example:

assertThat(person).prop(Person::name).isEqualTo("Sue")

Parameters

property

Property on which to assert. The name of this property will be shown in failure messages.


fun <T, R, F : (T) -> R, KCallable<R>> Assert<T>.prop(callable: F): Assert<R>

Returns an assert that asserts on the result of calling the given function.

Example:

assertThat(person).prop(Person::nameAsLowerCase).isEqualTo("sue")

Parameters

callable

Callable on which to assert. The name of this callable will be shown in the failure messages.