fun <T> assertThat(actual: T, name: String? = null): Assert<T>
Platform and version requirements: Common
Asserts on the given value with an optional name.
assertThat(true, name = "true").isTrue()
fun <T> assertThat(getter: KProperty0<T>, name: String? = null): Assert<T>
Platform and version requirements: Common
Asserts on the given property reference using its name, if no explicit name is specified. This method should be preferred in cases, where property references can be used, as it uses the property's name for the assertion automatically. The name may optionally be overridden, if needed.
data class Person(val name: String)
val p = Person("Hugo")
assertThat(p::name).contains("u")
fun <T> assertThat(f: () -> T): AssertBlock<T>
Platform and version requirements: Common
Asserts on the given block. You can test that it returns a value or throws an exception.
assertThat { 1 + 1 }.returnedValue {
isPositive()
}
assertThat {
throw Exception("error")
}.thrownError {
hasMessage("error")
}