Search code examples
scalamockingscalatest

Can you capture and inspect arguments supplied to a method under test with ScalaMock?


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?


Solution

  • 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).