Java Enumerating list in mockito's thenReturn
问题 Is there a way to enumerate the items in a list within mockito's thenReturn function so I return each item in a list. So far I've done this: List<Foo> returns = new ArrayList<Foo>(); //populate returns list Mockito.when( /* some function is called */ ).thenReturn(returns.get(0), returns.get(1), returns.get(2), returns.get(3)); This works exactly how I want it to. Each time the function is called, it returns a different object from the list, e.g get(1) , get(2) etc. But I want to simplify this