Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] suppressing warnings



2006/4/12, Ron Bodkin <rbodkin@xxxxxxxxxxxxxx>:

With this warning, I'm actually struck by how often it is valid to swallow
exceptions: sometimes an exception is really expected logic and should be
ignored (or even NOT having an exception is the exception)...  Certainly in
error handling tests this happens a lot.

Are you talking about unit tests that check if an exception is thrown under certain conditions? What I do in such cases is at least print out the exception message, something like:

catch( MyException e )
{
     _LOG.debug( "Expected exception: " + e.getMessage());
}

A better alternative for this use case is using TestNG, you can declare that your test method should throw a certain exception without using the fail()/empty catch block mechanism that everybody uses in JUnit.

regards,

Wim

Back to the top