有没有办法让存根方法在后续调用中返回不同的对象?我想这样做是为了测试ExecutorCompletionService
人的不确定性react .i、 e.测试结果是否保持不变,无论方法的返回顺序如何.
我要测试的代码如下所示.
// Create an completion service so we can group these tasks together
ExecutorCompletionService<T> completionService =
new ExecutorCompletionService<T>(service);
// Add all these tasks to the completion service
for (Callable<T> t : ts)
completionService.submit(request);
// As an when each call finished, add it to the response set.
for (int i = 0; i < calls.size(); i ++) {
try {
T t = completionService.take().get();
// do some stuff that I want to test
} catch (...) { }
}