axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Glen Daniels <>
Subject Coding Style Tip #487 - JUnit and Exceptions
Date Tue, 20 Mar 2007 00:55:54 GMT

I see a lot of this kind of thing in tests all over our source tree:

public void testSomething() {
     try {
         do something;
     } catch (Exception e) {
         fail(" An Exception has occured " + e.getMessage());

Please don't do this.  The following is much nicer and lets JUnit deal 
with the exceptions (which it does quite well)...

public void testSomething() throws Exception {
     do something;

This has been a public service announcement.  We now return you to your 
regularly scheduled feature (or bug? :)).


P.S.  See 
for a little more on this.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message