dev@jax-ws.java.net

[HEADS UP] Don't catch exceptions in unit tests

From: Kohsuke Kawaguchi <kohsuke.kawaguchi_at_sun.com>
Date: Mon, 30 Jan 2006 10:16:28 -0800

I see many tests written like this:

     public void testParameterOrder() throws Exception{
         try{
             ... real test code ...
         }catch(Exception e){
             e.printStackTrace();
             assertTrue(false);
         }
     }

This is a bad idea, because it's verbose and it hides the exception from
JUnit. The code should be written simply as:

     public void testParameterOrder() throws Exception {
         ... real test code ...
     }

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com