| Author |
About Mockito exceptions
|
robert isidorson
Greenhorn
Joined: Sep 03, 2007
Posts: 19
|
|
When i verify a method in a mock i still have to care about catching the exception even though it's a mock!
try {
verify(session, times(5)).init();
} catch(IOException e) {
;
}
how can i avoid that?
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26184
|
|
Robert,
You can have your test method say "throws Exception" and let JUnit deal with it. I actually recommend that; especially over silently ignoring the exception as you are doing. For Exception, it is possible for the mock to throw it and then you don't know your setup is wrong.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: About Mockito exceptions
|
|
|