Verify exact number of invocations within verifyOrder

380 views Asked by At

I want to verify that a number of functions were called in a specific order, but one of the functions gets called N times:

verifyOrder {
    myMockObject.func1()
    (exactly = 10) myMockObject.func2()
    myMockObject.func3()
}

How do I specify the "exactly = 10" above?

1

There are 1 answers

3
João Dias On BEST ANSWER

That is not possible. Your best option would be verifySequence, which verifies that the calls happened in a specified sequence.

verifySequence {
   myMockObject.func1()
   myMockObject.func2()
   myMockObject.func2()
   myMockObject.func2()
   myMockObject.func2()
   myMockObject.func2()
   myMockObject.func2()
   myMockObject.func2()
   myMockObject.func2()
   myMockObject.func2()
   myMockObject.func2()
   myMockObject.func3()
}

It is not pretty, but to my knowledge, you have no better alternative.