Skip to content

Instantly share code, notes, and snippets.

@donchan922
Last active July 11, 2019 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donchan922/42f3f47180e037aba330272b60e4d429 to your computer and use it in GitHub Desktop.
Save donchan922/42f3f47180e037aba330272b60e4d429 to your computer and use it in GitHub Desktop.
List mockedList = mock(List.class);
// 基本形
Mockito.when(mockedList.get(0))
.thenReturn("one")
.thenReturn("two")
.thenReturn("three");
// 短縮形
Mockito.when(mockedList.get(0)).thenReturn("one", "two", "three");
System.out.println(mockedList.get(0)); // one
System.out.println(mockedList.get(0)); // two
System.out.println(mockedList.get(0)); // three
System.out.println(mockedList.get(0)); // three
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment