JUnit test exception handling fail 2

Posted by Jens J├Ąger on May 09, 2011

I just found this peace of code in a big java project i’m working on:

Wtf? I changed it to:

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. Stefan Wed, 24 Aug 2011 18:49:44 CET

    The stacktrace gets lost with your modification. Imho, the best alternative would be to not catch the exception at all and change the throws clause of the method accordingly.

  2. Jens Wed, 07 Sep 2011 21:16:16 CET

    Hey Stefan,
    thanks for your reply. You are right. I have to say that in this case the stack trace was not very use full.

    Anyway with JUnit4 the @Text(expected = MyException.class) annotation makes live much easier.

    Jens

Comments

Information about Data protection