Код: Выделить всё
@Test(expectedExceptions = SomeException.class)
public void throwCheckedException() {
List list = mock(List.class);
when(list.get(0)).thenThrow(new SomeException());
String test = list.get(0);
}
public class SomeException extends Exception {
}
Код: Выделить всё
org.testng.TestException:
Expected exception com.testing.MockitoCheckedExceptions$SomeException but got org.mockito.exceptions.base.MockitoException:
Checked exception is invalid for this method!
Invalid: com.testing.MockitoCheckedExceptions$SomeException
Подробнее здесь: https://stackoverflow.com/questions/376 ... th-mockito
Мобильная версия