As per title, just wondering if there is a mechanism with easymock to test if a method wasn't called during it's lifetime.
As per title, just wondering if there is a mechanism with easymock to test if a method wasn't called during it's lifetime.
From the EasyMock documentation:
Nice Mocks
On a Mock Object returned by mock() the default behavior for all methods is to throw an AssertionError for all unexpected method calls. If you would like a "nice" Mock Object that by default allows all method calls and returns appropriate empty values (0, null or false), use niceMock() instead.
So what you are asking is the default behavior.
By default, Easymock will throw an exception for any methods that are called that you didn't explicitly set expectations for.
This worked for me:
eastMockObject.method(arg); EasyMock.expectLastCall().andStubThrow(new AssertionError());