doc / ch.tutteli.atrium.api.fluent.en_GB / because

because

fun <T> Expect<T>.because(reason: String, assertionCreator: Expect<T>.() -> Unit): Expect<T>

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

expect(12).because("this is true as anything can ever be") {
    toBe(12)
}

fails {
    expect(12).because("won't hold, it's not equal") {
        toBe(11)
    }
}

expect(listOf(1)).because("toBe is based on equality, use isSameAs for identity") {
    toBe(listOf(1))
}

fails {
    expect(arrayOf(1)).because("array has not implemented equals, so is equivalent to isSameAs") {
        toBe(arrayOf(1))
    }
}

Parameters

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

assertionCreator - The group of assertions to make.

Return
An Expect for the current subject of the assertion.

Since
0.15.0