(I couldn't fit "please" into the summary)
If the code under test happens to catch-and-swallow an AssertionError thrown by EasyMock, such as from an unexpected method call on a mock, the test might pass despite that error. If each control tracked the exceptions (such as AssertionError) thrown by mocks that it created, later its verify() method could report these and fail the test.
In the attached source example, the test subject happens to print the stack trace. But this could easily not be the case, and the offending (catch-and-swallow) code might be another (third-party) collaborator, not available to improve. Despite printing the error, this example clearly shows that it's possible to fail replay without failing the test, because the control needs an AssertionError to propagate all the way out of the code under test to the unit test framework during replay. The control could quite easily take advantage of the second opportunity to complain during verify().
Log in to post a comment.