I have strange behaviour. I have a unit-test that does some stuff and then performs the following verification statements:
verify(exactly = 2) {
observer.onThingChanged()
}
verify(exactly = 1) {
b.addThing(thing)
}
verify(exactly = 0) {
observer.onAnotherThingChanged(any())
}
This test fails on the second call to verify()
with the following error:
java.lang.AssertionError: Verification failed: call 1 of 1: Observer(#2).onThingChanged()).
2 matching calls found, but needs at least 1 and at most 1 calls
Calls:
1) Observer(#2).onThingChanged()
2) Observer(#2).onThingChanged()
This makes no sense. It seems to be using the "exactly" parameter from the second verify()
call, but the code block from the first verify()
call.
Am I missing something? Are multiple calls to verify()
with different exactly=
arguments supported?