0

Here is the pseudocode of my unit test:

int invocationCount
given(mock).willDo {
    invocationCount++
    return value
}
doSomeProcessing()
verify(mock)
doSomeMoreProcessing()
verifyCount(mock, 2)

At this point, invocationCount == 2, as expected. However, verifyCount fails, saying it was only called once. In addition, if I exclude the first verify call, the test passes as expected. It might be relevant to note that each verify call is capturing a new argument for assertion later.

My question is this: when the first verify() is called, is the mock's invocation count reset? If this is not the case, what could be happening?

cohenadair
  • 2,072
  • 1
  • 22
  • 38

1 Answers1

1

Yes, verification only counts the matches since the last verification.

Further discussion can be found here: https://github.com/jonreid/OCMockito/issues/116

Jon Reid
  • 20,545
  • 2
  • 64
  • 95