解决方法
使用EasyMock,您可以创建一个漂亮的模拟,与普通模拟对象不同,如果发生意外/记录的呼叫,则不会发出断言错误.引用easymock文档…
On a Mock Object returned by createMock() 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 createNiceMock() instead.
要创建一个漂亮的模拟,请在Easymock类上使用静态createNiceMock(Class类)方法…
SomeClass someClassNiceMock = EasyMock.createNiceMock(SomeClass.class);