#24 make verify() fail when an earlier error had been thrown

EasyMock (33)
kind heart

(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().


  • kind heart

    kind heart - 2009-05-22

    demonstration of problem

  • Henri Tremblay

    Henri Tremblay - 2009-05-23

    I see your point here. A code that swallow an AssertionError would seem like very bad code... But yes, it can happen.

    My only problem about this is that I think it will clash with issue 1896509.

    A least, it can't be in verify. I would need a new method for this.

  • Comment has been marked as spam. 

    You can see all pending comments posted by this user  here

    Anonymous - 2011-10-20

    Excuse me, Henri, I couldn't find the issue 1896509 you mention on your comment.
    I'm interested in working with this, but I don't want my solution to clash with the issue.

    I would appreciate if you could tell me about it or link me to it.


    Last edit: Anonymous 2013-11-20

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks