Clone this wiki locally
Occurrences let you specify a scheme for invoking a method within a scenario.
The most common occurrence is "invoked exactly N times", expressed by
willInvoke(N). But you may need more sophisticated schemes sometimes.
com.vmware.lmock.checker.Occurrences define the following types of occurrences:
exactly(N): exactly N times (i.e.
willInvoke(N)is strictly equivalent to
any: can happen any number of times (including never)
atLeast(N): the expectation is met if and only if the invocation occurs N or more times
atMost: the expectation is met if the invocation does not occur more than N times (including never)
between(N,M): to meet the expectation, the invocation should occur at least N times and never more than M times
Please pay a careful attention when using occurrences, in the sense that their combinations may sometimes become confusing (for example, the same invocation that should happen at most 3 times and then exactly one time). Lmock does not implement any mechanism to prevent from ambiguous occurrence specifications.