Wanted: doAnswer equivalent for doThrow?

537 views
Skip to first unread message

Mark Derricutt

unread,
Apr 14, 2012, 6:27:03 AM4/14/12
to moc...@googlegroups.com
Hey all,

I have a situation when I want to mock a method to throw an exception,
but I want to construct that exception manually based on arguments given
to the method similar to doAnswer.

Does Mockito have anything like this currently? And if not - would I be
crazy to ask for such a thing, or should I try and rework my tests?

Mark

David Wallace

unread,
Apr 14, 2012, 6:30:34 AM4/14/12
to moc...@googlegroups.com
Just make an Answer that throws whatever you need it to throw.

Cheers,
David.

Hey all,

Mark

--
You received this message because you are subscribed to the Google Groups
"mockito" group.
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.

Mark Derricutt

unread,
Apr 14, 2012, 6:34:00 AM4/14/12
to moc...@googlegroups.com
Ahh good point! I didn't think about throwing an exception just from an
Answer. Works perfectly :)

+1

Reply all
Reply to author
Forward
0 new messages