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