How to expect void method call with any argument using EasyMock

北城余情 提交于 2019-12-23 09:03:27

问题


As a part of unit test I need to mock a void function(Which accept any non-primitive paramter. e.g. MAP) call with any argument.

mockObj.myMethod(<anyObject>)

Is it possible to do this with EasyMock?


回答1:


Use either of the anyObject methods: anyObject() or anyObject(T)

So

 expect(mockObj.myMethod(anyObject()));

See the Flexible Expectations with Argument Matchers section of the documentation



来源:https://stackoverflow.com/questions/17123993/how-to-expect-void-method-call-with-any-argument-using-easymock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!