Is it against best practice to throw Exception on most JUnit tests?

Posted by Chris Knight on Stack Overflow See other posts from Stack Overflow or by Chris Knight
Published on 2010-03-22T23:36:21Z Indexed on 2010/03/22 23:41 UTC
Read the original article Hit count: 268

Filed under:
|
|

Almost all of my JUnit tests are written with the following signature:

public void testSomething() throws Exception

My reasoning is that I can focus on what I'm testing rather than exception handling which JUnit appears to give me for free. But am I missing anything by doing this? Is it against best practice? Would I gain anything by explicitly catching specific exceptions in my test and then fail()'ing on them?

© Stack Overflow or respective owner

Related posts about java

Related posts about unit-testing