If I want to verify either that no errors or some errors have been logged, but there are multiple error logging methods, I could do something clumsy like this:
Logger log = mock(Logger.class);
boolean errorsExpected;
...
if (errorsExpected) {
try {
verify(log, atLeastOnce()).error(any());
} catch (AssertionError e) {
verify(log, atLeastOnce()).error(any(), any());
}
} else {
verify(log, never()).error(any());
verify(log, never()).error(any(), any());
}
Is there a better way?