Skip to search.
easymock

Group Information

  • Members: 431
  • Category: Software
  • Founded: Feb 5, 2002
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Messages

  Messages Help
Advanced
Catching exceptions in other threads   Message List  
Reply Message #494 of 1660 |
Re: [easymock] Catching exceptions in other threads


Hello Marcel,

> I currently have a unit test that tests a class that spawns a
> background
> thread to do some processing. The processing itself uses some mock
> objects. The problem I have is that if a call to a mock object in this
> thread fails, an exception is thrown and I see a nice stack trace
> on the
> console, but the test still "succeeds".

Let's say the exception would be thrown by a real implementation,
and *not* by EasyMock. How would your application know that the
calculation went wrong?


> Is it somehow possible to make the test fail in such a scenario? I was
> hoping that the call to "verify()" would have remembered that
> something
> went wrong, but it doesn't.

EasyMock matches expected and actual calls. Whenever an unexpected
call occurs, an exception is thrown, and the call does not get recorded.
verify() just checks whether all expected calls were recorded.
Usually this is not a problem, since your test should fail at the first
exception.


-
Tammo



Thu Oct 6, 2005 3:15 pm

tammofreese
Offline Offline
Send Email Send Email

Message #494 of 1660 |
Expand Messages Author Sort by Date

I'm sorry if this is a FAQ, but as far as I could see it wasn't answered before. I currently have a unit test that tests a class that spawns a background ...
Marcel Offermans
marcel.offermans@... Send Email
Oct 6, 2005
2:44 pm

Hello Marcel, ... Let's say the exception would be thrown by a real implementation, and *not* by EasyMock. How would your application know that the calculation...
Tammo Freese
tammofreese Offline Send Email
Oct 6, 2005
3:15 pm

... In this case, the code is deployed in a headless embedded device and the exception gets logged. So what I'm actually doing is mocking the log service...
Marcel Offermans
marcel.offermans@... Send Email
Oct 6, 2005
3:25 pm
Advanced

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help