You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Glen Daniels <gl...@thoughtcraft.com> on 2007/03/20 02:00:11 UTC

[axis2] Coding Style Tip #487 - JUnit and Exceptions

Resending with [axis2] prefix, as it's meant to refer mostly to the A2 
codebase.

--G

-------- Original Message --------
Subject: Coding Style Tip #487 - JUnit and Exceptions
Date: Mon, 19 Mar 2007 20:55:54 -0400
From: Glen Daniels <gl...@thoughtcraft.com>
Reply-To: axis-dev@ws.apache.org
To: Axis-Dev <ax...@ws.apache.org>

Folks:

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) {
         e.printStackTrace();
         log.error(e.getMessage());
         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? :)).

--Glen

P.S.  See
http://www.exubero.com/junit/antipatterns.html#Catching_Unexpected_Exceptions 

for a little more on this.

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org