because

infix fun <T> Expect<T>.because(keyWithCreator: KeyWithCreator<String, T>): Expect<T>(source)

Allows to state a reason for one or multiple assertions for the current subject.

Return

an Expect for the subject of this expectation.

Since

0.15.0

Parameters

keyWithCreator

Combines the reason with the assertionCreator-lambda. Use the function of(reason) { ... } to create a KeyWithCreator.

Samples

data class Person(val age: Int)
val customers = listOf(Person(21))

expect("filename") because of("? is not allowed in file names on Windows") {
    it notToContain "?"
}

expect(customers) toHaveElementsAndAll (fun Expect<Person>.() {
    it because of("the legal age of maturity in Switzerland is 18") {
        feature { f(it::age) } toBeGreaterThanOrEqualTo 18
    }
})