HOD*_*HOD 6 junit android unit-testing mockito
我正在尝试编写一个Junit测试,它将验证是否调用了以下方法:
public long executeRequest(@RequestCodes.Code.RequestAnnotation int requestCode, Object requestInformation, RequestListener requestListener) {
boolean success = false;
... do stuff ...
return success ? 1L : -1L;
}
Run Code Online (Sandbox Code Playgroud)
在测试中使用:
Mockito.when(mockedRequest.executeRequest(Matchers.any(RequestCodes.Code.RequestAnnotation.class), Matchers.any(RequestWrapper.class), Matchers.any(RequestListener.class))).thenReturn(1L);
Run Code Online (Sandbox Code Playgroud)
RequestCodes.Code.RequestAnnotation类是一个基本的indef接口,使用int来标识使用开关进行的调用.非常喜欢这个.
Matchers.any(RequestCodes.Code.RequestAnnotation.class)
不会在这里工作,我都试过Matchers.any()
,Matchers.anyInt()
,Matchers.isA(RequestCodes.Code.RequestAnnotation.getClass())
(以及别的来考虑),但没有成功.
任何建议将不胜感激.
归档时间: |
|
查看次数: |
622 次 |
最近记录: |