because

fun <T> Expect<T>.because(reason: String, assertionCreator: Expect<T>.() -> Unit): 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

reason

The explanation for the assertion(s) created by assertionCreator.

assertionCreator

The group of assertions to make.

Samples

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

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

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