Hi devs:
Take a look at this code from one of our tests.
try {
registry.rateResource("/d16/d17/r1", 5);
} catch (RegistryException e) {
fail("Couldn't rate the resource /d16/d17/r1");
}
Let's say there's an exception during the rateResource() call. What
happens? Well, we get an output message which says "Couldn't rate the
resource /d16/d17/r1"... and that's all. Hm, doesn't seem very useful
for debugging, does it?
Whereas on the other hand - if the test method was declared as "throws
RegistryException" instead, and we didn't bother catching it, we'd allow
the exception itself to bubble up through JUnit, and we'd see A STACK
TRACE when the test failed, giving anyone trying to fix such a problem a
whole lot more information.
This kind of anti-pattern is all over our test framework. Please don't
do this for any new tests you write, and please fix it whenever you're
in code that does this kind of thing. Test methods should *only* catch
expected Exceptions (when testing failure conditions for instance).
Other Exceptions should simply be propagated upwards.
Thanks,
--Glen
_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev