我正在尝试验证我的mockResource调用getQuantityString()传递正确的数量。
getQuantityString()的实际代码
resources.getQuantityString(R.plurals.SUCCESS,5,5);
在测试:@Captor private ArgumentCaptor<Integer> firstIntegerCaptor;
verify(resources).getQuantityString(isA(int.class),firstIntegerCaptor.capture(), any());
I got error in below.
org.mockito.exceptions.verification.junit.ArgumentsAreDifferent:
Argument(s) are different! Wanted:
resources.getQuantityString(
isA(int),
<Capturing argument>,
<any>
);
Actual invocation has different arguments:
resources.getQuantityString(
2131165186,
5,
5
);
我检查这个函数的原型。
public String getQuantityString(int id, int quantity, Object... formatArgs)
是错误的,因为对象…formatArgs或Integer不匹配int?
使用
verify(resources).getQuantityString(anyInt(),firstIntegerCaptor.capture(), Matchers.<Object>anyVararg());