The Java Mocking framework Mockito has a utility class called ArgumentCaptor
that accumulates a list of values as a method under verification is invoked multiple times.
Does ScalaMock have a similar mechanism?
There's an under the hood mechanism that does this in the preview release of ScalaMock3, but it's not currently exposed to client code.
What's your use case for this?
You might be able to achieve what you need by using where
or onCall
documented here (under the "Predicate matching" and "Return Value" headings respectively).
In Specs2 you can use the following:
myMock.myFunction(argument) answers(
passedArgument => "something with"+passedArgument
)
This maps to Mockito's ArgumentCaptor under the hood.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With