toHaveElementsAndAll

fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveElementsAndAll(assertionCreatorOrNull: Expect<E>.() -> Unit?): Expect<T>(source)

Expects that the subject of this expectation (an Iterable) has next element(s) and

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

expect(listOf(1, 2, 2, 4)).toHaveElementsAndAll { toBeGreaterThan(0) }
expect(listOf(null, null)).toHaveElementsAndAll(null)

fails {
    expect(emptyList<Int>()).toHaveElementsAndAll { toBeGreaterThan(0) }
}

fails {
    expect(listOf(1, 2, 2, 4)).toHaveElementsAndAll {
        toBeLessThanOrEqualTo(3)
    }
}