On 07/30/12 17:16, Russell Bateman wrote:
> I'm thinking that here, I should be able to say something tantamount to
>
> verify( object ).method( args ).throws( AppException )
>
> ...or something like that.
This would obscure several potentially valuable details post-throw. So
far I've always used the somewhat pedestrian:
try
{
mock.boom();
fail("no boom");
}
catch (BoomException boom)
{
// verify specific details, required/absent side effects etc.
}
Yes, it's more verbose. It also allows for exact inspection &
verification of possible side-effects, type/details on the thrown
exception, zero stray calls to other mocks etc.
Alternatively save the boilerplate and just mark your test method with
an appropriate JUnit expectation.
-h