【发布时间】:2016-09-12 12:18:47
【问题描述】:
我想做一个单元测试来验证是否调用了 function1() 或 function2()。我以前没有处理过回调,你能告诉我怎么做吗?
public void sendData(HttpService service, Document userData) {
Call<String> call = service.updateDocument(getId(), userData);
call.enqueue(new Callback<String>() {
@Override
public void onResponse(Call<String> call, Response<String> response) {
function1(response.code());
}
@Override
public void onFailure(Call<String> call, Throwable t) {
function2();
}
});
}
【问题讨论】:
标签: android unit-testing mockito powermock retrofit2