https://kotlinlang.org logo
#mockk
Title
# mockk
g

gildor

10/18/2018, 2:17 AM
Is there any way to emulate verifyNoInteractions from mockito? Because I found that I missed this verification method in some cases
o

oleksiyp

10/25/2018, 6:17 AM
Sorry for late reply, there is verifySequence / verifyAll that is doing same thing
g

gildor

10/25/2018, 6:31 AM
So actually verifySequence/verifyAll verifies all invocations inside of block and if there are any other interactions will throw a verification error?
o

oleksiyp

10/25/2018, 6:32 AM
yes, with following detail: verifySequence will also take into the regard order and verifyAll will not
g

gildor

10/25/2018, 6:33 AM
yeah, I got difference about order, it’s just not obvious that those operators also verify that no other interactions happened
Maybe make sense to add it exlicitly to docs otherwise it’s not obvious for me
I just thought that it shortcut for multiple verify calls
Anyway, thanks a lot for info
@oleksiyp One more question, can I somehow check that there is no interactions with mock. Now you must at least have one check inside of verifyOrder/verifyAll block
d

dave08

10/27/2018, 7:37 PM
I think it's
verify(exactly = 0) { }
@gildor, there's a bunch of interesting params to verify you might find useful...
o

oleksiyp

10/27/2018, 9:05 PM
Or
verify { mock wasNot called }
:-)
g

gildor

10/28/2018, 11:18 PM
Thanks. Dave, yeah, I use exactly param all the time, it's just not obvious that it will work like that. Isn't it inconsistent behavior verifyOrder throws an exception if no mock calls, but verify works properly?
Like
wasNot called
approach tho
41 Views