我有一个方法findSubmit。假设我在数组提交中可能返回值。现在,我正在按他们的指数返回。但是我想一个接一个地返回提交的所有值,而不是像我现在那样使用它们的索引。
when(submissionService.findSubmission(Mockito.anyLong())).thenReturn(submission[0], submission[1], submission[2], submission[3], submission[4])
您可以使用:
import org.mockito.AdditionalAnswers;
when(submissionService.findSubmission(Mockito.anyLong())).thenAnswer(AdditionalAnswers.returnsElementsOf(Arrays.asList(submission)));