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.

Use because of("reason") { ... } if you want to use it in an infix style.

Return

an Expect for the subject of this expectation.

Since

1.2.0

Parameters

reason

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

assertionCreator

The group of assertions to make.

Samples

ch.tutteli.atrium.api.fluent.en_GB.samples.DocumentationUtilSamples.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
    }
})