Setup code should be pretty simple and stable, so should very rarely suddenly start throwing new exceptions.
If you need to pinpoint which bit of code under test threw the exception, you're probably testing too much in one test.
Of course, the advice changes when you're using a unit testing framework as a runner for integration tests.
http://kentbeck.github.com/junit/javadoc/4.10/org/junit/rule...
This is more compact and declarative than the usual
try {
...;
fail();
} catch (...) {
// expected
}Firstly this is most useful when it's @Test(expected=SomeDomainSpecificException.class) NPEs can be thrown by anything.
Secondly, if you're following the other advice and have tests that test only one thing and assert only one thing then there should be only one line that can throw an Exception.