I have to test a method which uses a mutable object
private final List<LogMessage> buffer;
...
flushBuffer() {
sender.send(buffer);
buffer.clear();
}
I need to test that it sends buffers with exact size.
ArgumentCaptor
is not applicable because the captured collection is clear by the time of assertion.
Is there a kind of matcher which can reuse Hamcrest's hasSize()
and does check right in time of method call?
I would prefer something like this hypothetical collectionWhich
matcher:
bufferedSender.flushBuffer();
verify(sender).send(collectionWhich(hasSize(5)));
Aucun commentaire:
Enregistrer un commentaire