jocarreira / hamcrest

Automatically exported from code.google.com/p/hamcrest
0 stars 0 forks source link

BaseDescription.appendValue(Object) does not handle exceptions from String.valueOf(Object) #25

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hamcrest 1.1 with jUnit 4.4 and jMock 2.4.0 and IDEA 7.0.1

In the last else branch in BaseDescription.appendValue(Object) Throwable
isn't caught. This leads to hard to find bugs in tests when the hash code
of the object depends on (j)mock objects. In this case a
org.jmock.api.ExpectationError is thrown which causes an untraceable error
in the tests.

Original issue reported on code.google.com by jonas.be...@gmail.com on 15 Nov 2007 at 4:47

GoogleCodeExporter commented 8 years ago
Catching Throwable would make bugs even harder to find.

Code should almost never catch Throwable, and a Hamcrest matcher is the wrong 
place
to do this kind of error handling.

Original comment by nat.pr...@gmail.com on 2 Oct 2008 at 8:24

GoogleCodeExporter commented 8 years ago
I agree on your point about Throwables, off course.
But still, this case generates hard to find bugs.

Original comment by jonas.be...@gmail.com on 2 Oct 2008 at 9:41