I'm writing some Java unit tests for an existing class using Mockito. However, I'm having trouble extracting the arguments with which an object of this class is calling a method as part of a nested call.
Example:
public class SomeClass {
public SomeClass() {
//...
}
public someMethod(Foo foo) {
// Bar bar = ...
someOtherMethod(bar);
}
private someOtherMethod(Bar bar) {
//...
}
}
I want to capture the arguments to someOtherMethod()
and verify that bar
is what it should be. Can I do this using ArgumentCaptor
or other functionality within Mockito?