Last active
August 11, 2018 02:58
-
-
Save ytnk531/32ec191cfd6beedf6919546226531f06 to your computer and use it in GitHub Desktop.
Runnerを使う
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Assert; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.mockito.Mock; | |
import org.mockito.junit.MockitoJUnitRunner; | |
import java.util.List; | |
import static org.mockito.ArgumentMatchers.anyInt; | |
import static org.mockito.Mockito.when; | |
@RunWith(MockitoJUnitRunner.class) | |
public class MockTest { | |
@Mock | |
private List mockedList; | |
@Test | |
public void test1() { | |
when(mockedList.get(anyInt())) | |
.thenReturn(500); | |
Object actual = mockedList.get(120); | |
Assert.assertEquals(500, actual); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment