Mockingbird Documentation 0.16.0

Function at​Least(_:​)

public func atLeast(_ times: Int) -> CountMatcher

Matches greater than or equal to some count.

The atLeast count matcher can be used to verify that the actual number of invocations received by a mock is greater than or equal to the expected number of invocations.

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

verify(bird.fly()).wasCalled(atLeast(1))  // Passes
verify(bird.fly()).wasCalled(atLeast(2))  // Passes
verify(bird.fly()).wasCalled(atLeast(3))  // Fails (n < 3)

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

verify(bird.fly()).wasCalled(atLeast(once))

Parameters

times Int

An inclusive lower bound.

Returns

A count matcher.