我有静态方法,我想捕获 varargs
Executor ex = new Executor();
ex.execute(String nodeName, boolean status, Property ... properties);
ArgumentCaptor<Property> propertyCaptor = ArgumentCaptor.forClass(Property.class);
verify(ex).execute(anyString(), anyBoolean(), propertyCaptor.capture);
propertyCaptor .getValue() - 无效????
答案 0 :(得分:1)
我不确定你到底要测试的是什么,但以下是有效的:
class SpecialExecutor implements Executor {
@Override
public void execute(Runnable command) {
}
public void execute(String nodeName, boolean status, Property... properties) {
}
};
@Test
public void test() {
SpecialExecutor ex = new SpecialExecutor();
ArgumentCaptor<Property> propertyCaptor = ArgumentCaptor.forClass(Property.class);
verify(ex).execute(anyString(), anyBoolean(), any(Property[].class));
}