Mockingbird Documentation 0.14.1

Function between(_:​)

public func between(_ range: Range<Int>) -> CountMatcher

Matches counts that fall within some range.

The between count matcher can be used to verify that the actual number of invocations received by a mock is within an inclusive range of expected invocations.

// Given two invocations (n = 2)
bird.fly()
bird.fly()

verify(bird.fly()).wasCalled(between(1...2))  // Passes
verify(bird.fly()).wasCalled(between(3...4))  // Fails (3 &nlt; n < 4)

You can combine count matchers with adverbial counts for improved readability.

verify(bird.fly()).wasCalled(between(once...twice))

Parameters

range Range<Int>

An closed integer range.

Returns

A count matcher.