I would like to doNothing 29 times and when 30 time calling happens, then throw ArithmeticException
. But i cannot find anything where to set TIMES attribute.
This is my imagination:
@Mock
DAOclass dao;
@Test(expected = ArithmeticException.class)
public void AAA() throws SQLException {
doThrow(ArithmeticException.class).when(dao,times(30)).methodABC();
for (int i = 0; i < 30; i++) {
dao.nothing();
}
}
But of course when(dao,times(30))
is nonsense because i cannot add times(30) as second argument at when block.
Does somebody have some idea what could be optional solution of this problem?
Btw. my target is definitely not MANUALLY write 30 times doNothing().doNothing().doNothing.... doThrow(...).when(...)