I have the following line in my test:
Capture<MyType> myCapture = Capture.newInstance();
expect(myMockedObject.myMethod(capture(myCapture)).andReturn(...).times(2);
This expectation passes when the mocks are verified but myCapture.getValues().size()
returns 1. I am expecting a capture for each method call. How can I capture the arguments to both method calls?
There is a parameter, called CaptureType
that determines what gets captured. By default, this parameter is set to CaptureType.LAST
, which only captures the last invoked method parameter. To fix this, create the capture like so:
Capture<MyType> myCapture = Capture.newInstance(CaptureType.ALL);
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