Menu

#30 Assertion in finally block hides the real failure

EasyMock_2.5
open
EasyMock (33)
3
2012-10-05
2009-10-12
No

Submitted by virtualwarp

I have an issue when testing code that has a try-finally block.

When I run a test for code containing a try-finally block, easymock
reports the last unexpected call. If an expectation in the try-block fails,
the expectation in the finally-block will also fail. Since the last failure
is reported, the original reason for the failure is no longer visible.

Example:

mock.write(2);
mock.close();
replay();

try {
mock.write(1);
} finally {
mock.close();
}

verify();

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.