toHaveNext

Expects that the subject of this expectation (an Iterator) has a next element.

Return

an Expect for the subject of this expectation.

Since

0.17.0

Samples

val iterator = listOf(1).iterator()

expect(iterator).toHaveNext()      // holds as iterator has a next element

fails {
    iterator.next()                // returns the next element in iteration
    expect(iterator).toHaveNext()  // fails as list has only 1 element, i.e. no next any more.
}