Re: [mockito-flex] verification of a method stub

10 views
Skip to first unread message
Message has been deleted

Kris

unread,
Oct 4, 2010, 7:28:39 AM10/4/10
to mockit...@googlegroups.com
Can you explain what is that you are trying to test here?

Mockito - in contrast to expectation based mock frameworks - does not require defining any invocations upfront. If your tested code simply calls some external dependency that you mock, it's enough to call verify() to check whether the expected function got called. So no need to define any stubbing here.

If you try to ensure your service executed whatever you provided in stub definition I would think you'd rather verify the actual result of it instead of making sure the invocation happened. In your case the service call probably modifies the system with new search results and that's what I would assert on.

I can't recall at this point if it was possible to verify on stubbed invocations or not. I need to take a look at the code and will come back to you.

Hope this helps,
Kris

pbuda

unread,
Oct 4, 2010, 7:43:39 AM10/4/10
to mockito-flex
I'm sorry - I've deleted the message, but must have missed your post.

The problem was that in the tested model this service's method was
called with 3 arguments (4th being optional) but in test it was
stubbed with 4 args. Adding null to service call, or stubbing with
just 3 args, solves the issue.

The service accepts an onResult method that does something. In this
particular case it's not necessary to verify that, however I was
playing with invocation stubbing and stuck with this irrelevant test
case.

Kris

unread,
Oct 4, 2010, 7:53:15 AM10/4/10
to mockit...@googlegroups.com
Oh yeah optional parameters require some more work.

Glad it works for you now.

Cheers,
Kris


Reply all
Reply to author
Forward
0 new messages