Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. List mockedList = mock(List.class);
  2.  
  3. // 基本形
  4. Mockito.when(mockedList.get(0))
  5. .thenReturn("one")
  6. .thenReturn("two")
  7. .thenReturn("three");
  8.  
  9. // 短縮形
  10. Mockito.when(mockedList.get(0)).thenReturn("one", "two", "three");
  11.  
  12. System.out.println(mockedList.get(0)); // one
  13. System.out.println(mockedList.get(0)); // two
  14. System.out.println(mockedList.get(0)); // three
  15. System.out.println(mockedList.get(0)); // three
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement