--
You received this message because you are subscribed to the Google Groups "mockito" group.
To view this discussion on the web visit https://groups.google.com/d/msg/mockito/-/cQgKUO6BBfkJ.
To post to this group, send email to moc...@googlegroups.com.
To unsubscribe from this group, send email to mockito+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mockito?hl=en.
You've stepped on one of the syntax limitations I'm afraid:verify(mockedProcessRepository).delete(mockedProcessRepository.findByUuid(PROCESS01_ID));or simpler:verify(mock).foo(mock.bar());is not supported. Mockito does not know which method should verify foo() or bar(). It cannot be fixed due to language and syntax choices. More over we cannot even give any warning (unless someone has some brillant idea? :) However, if only you have used different mocks, such syntax would have worked:verify(mock).foo(mockTwo.bar()); //worksIt's because when different mocks are used in that use case, Mockito has chance to distinguish between the verified call and the 'auxiliary' call.
The only choice you have is to separate the 'auxiliary' call:Bar bar = mock.bar();verify(mock).foo(bar);
Hope that helps!
To unsubscribe from this group, send email to mockito+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mockito?hl=en.
HiAm Dienstag, 6. März 2012 12:30:07 UTC+1 schrieb szczepiq:You've stepped on one of the syntax limitations I'm afraid:
verify(mockedProcessRepository).delete(mockedProcessRepository.findByUuid(PROCESS01_ID));or simpler:verify(mock).foo(mock.bar());is not supported. Mockito does not know which method should verify foo() or bar(). It cannot be fixed due to language and syntax choices. More over we cannot even give any warning (unless someone has some brillant idea? :) However, if only you have used different mocks, such syntax would have worked:verify(mock).foo(mockTwo.bar()); //worksIt's because when different mocks are used in that use case, Mockito has chance to distinguish between the verified call and the 'auxiliary' call.Thanks for the explanation. This explains the TooManyActualInvocations error.The only choice you have is to separate the 'auxiliary' call:Bar bar = mock.bar();verify(mock).foo(bar);This is what I tried in the test method deleteFailsToo in my original post. In this case mockito means that foo has not been called with bar as argument, whereas I'm absolutely sure it has been called this way.Any ideas why I get the "Wanted but not invoked" error in this case?
To view this discussion on the web visit https://groups.google.com/d/msg/mockito/-/XTkazmkO-sgJ.
To unsubscribe from this group, send email to mockito+u...@googlegroups.com.
Not directly connected to your question, but to simplify mock creation
in a Spring context (and get some new interesting features like
overriding real beans already defined in a Spring context) your can
also take a look at Springockito:
https://bitbucket.org/kubek2k/springockito/wiki/Home
Regards
Marcin
> - Why does the deleteShouldSucceed fail?
> - Why does strangeTooManyInvocationsError verify the invocations of
> findByUuid?
> - What could be the reason for this behavior?
>
> I'm clueless...
>
> Best regards,
> James
>
--
http://blog.solidsoft.info/ - Working code is not enough
Gasp!
Spring: "We will add your technological distinctiveness to own. Your
technology will adapt to serve us. Resistance is futile."
Hehehe...
:-)