![](/img/trans.png)
[英]EasyMock number of “expected” calls is greater than the value set in “times” method
[英]Capture arguments to expected method calls multiple times (EasyMock)
我的测试中有以下几行:
Capture<MyType> myCapture = Capture.newInstance();
expect(myMockedObject.myMethod(capture(myCapture)).andReturn(...).times(2);
当myCapture.getValues().size()
被验证但myCapture.getValues().size()
返回1.我期望捕获每个方法调用。 如何捕获两个方法调用的参数?
有一个名为CaptureType
的参数可以确定捕获的内容。 默认情况下,此参数设置为CaptureType.LAST
,它仅捕获上次调用的方法参数。 要解决此问题,请像这样创建捕获:
Capture<MyType> myCapture = Capture.newInstance(CaptureType.ALL);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.