infix fun <T> Expect<T>.because(keyWithCreator: KeyWithCreator<String, T>): Expect<T>
Allows to state a reason for one or multiple assertions for the current subject.
expect(12) because of("this is true as anything can ever be") {
toBe(12)
}
fails {
expect(12) because of("won't hold, it's not equal") {
toBe(11)
}
}
expect(listOf(1)) because of("toBe is based on equality, use isSameAs for identity") {
toBe(listOf(1))
}
fails {
expect(arrayOf(1)) because of("array has not implemented equals, so is equivalent to isSameAs") {
toBe(arrayOf(1))
}
}
keyWithCreator
- Combines the reason with the assertionCreator-lambda. Use the function
of(reason) { ... }
to create a KeyWithCreator.
Return
An Expect for the current subject of the assertion.
Since
0.15.0