I\'m trying to mock up some mongo classes so that I don\'t need a connection (fairly standard stuff) but the following code gives me problems:
when(dbCollect
I think your results are compatible with the result that would happen if dbCollection
is not a Mockito-mock (or your method is static or final). That would mean that a matcher is being used where none can be used; hence the "0 matchers expected, 1 recorded".
This same issue can be reproduced in Scala if you have default arguments. It may look like you're providing any() for every argument, but you should verify that the method definition doesn't have any default parameters which might be messing things up.
Probably unrelated, but I encountered the same error when I spied a package private method. Changing it to public solved the issue for me.