Thanks Brice. You helped me understand the problem. The sample I posted is not exactly what I intended to be; the following is:
@Test public void testVerifyConsecutiveCalls() {
List mock = mock(List.class);
when(mock.get(0)).thenReturn("a").thenReturn("b");
mock.get(0); //first call
mock.get(0); //second call
verify(mock).get(anyInt()); // I want this line to match the first call
verify(mock).get(anyInt()); // I want this link to match the second call
}
The problem is that the first "verify" matches both calls instead of only one. I could change it to:
order.verify(mock, times(2)).get(anyInt());
//order.verify(mock).get(anyInt());
I guess mockito does not work like "match only one and then leave the rest to the other versifiers ".