Mockito.doThrow()



Example:
@Test
public void test_doThrow(){
ArrayList  list = Mockito.mock(ArrayList.class);
Mockito.doThrow(new Exception()).when(list).clear();
}
Here it will throw Exception whenever you call list.clear() method