|
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
|