Skip to content

Instantly share code, notes, and snippets.

@donchan922
Created July 11, 2019 14:04
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/5c02ed682fec5958edbdc0b49b4c90bc to your computer and use it in GitHub Desktop.
Save donchan922/5c02ed682fec5958edbdc0b49b4c90bc to your computer and use it in GitHub Desktop.
List mockedList = mock(List.class);
Mockito.when(mockedList.get(0))
.thenReturn("one")
.thenReturn("two")
.thenThrow(new RuntimeException());
System.out.println(mockedList.get(0)); // one
System.out.println(mockedList.get(0)); // two
System.out.println(mockedList.get(0)); // RuntimeExceptionが発生する
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment