java 使用easymock,重复void方法调用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1222076/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using easymock, repeated void method call
提问by Hendrik
I am new to easymock.
我是easymock的新手。
I am trying to mock a service where one of the methods is a void method that will get called an unknown (and large) number of times. How do I specify that any number of calls is allowed?
我正在尝试模拟一个服务,其中一个方法是一个 void 方法,该方法将被调用未知(和大量)次数。如何指定允许任意数量的调用?
I know how to do it for methods that have a non-void return type.
我知道如何为具有非 void 返回类型的方法执行此操作。
Thanks
谢谢
回答by Arne Burmeister
Call the void method of the mock. Afterwards use EasyMock.expectLastCall().anyTimes()
调用模拟的 void 方法。之后使用EasyMock.expectLastCall().anyTimes()

