when(i.next()).thenReturn("Hello").thenReturn("World");
when(c.compareTo("Test")).thenReturn(1);
when(c.compareTo(anyInt())).thenReturn(-1);
doThrow(new IOException()).when(mock).close();
verify:确认某个方法被调用过
verify(mock).close();
verify(mock).write(argThat(arrayStartingWithA), eq(0),eq(1));
参考链接:http://gojko.net/2009/10/23/mockito-in-six-easy-examples/