import static org.mockito.Mockito.when; import java.util.List; import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; import org.testng.Assert; import org.testng.annotations.Listeners; import org.testng.annotations.Test; @Listeners(MockitoTestNGListener.class) public class MockitoTest { @Mock List mockList; @Test void mock_list_returns_correct_elements() { when(mockList.get(0)).thenReturn("foo"); Assert.assertEquals(mockList.get(0), "foo"); } }