This is about verification, not about mocking - yes, deep stubs will do exactly what you mention (as will a fake). The key here is
verifying later.
I'll try to make a better example (apologies). Here's the code to be tested (this is grossly oversimplified, of course)
class SomeClass {
SomeResult doSomething();
}
class SomeResult {
List<String> makeRpcCall();
}
class ToBeTested {
SomeClass some;
void doStuff() {
some.doSomething().makeRpcCall();
}
}
We can either do deep stubs here, or better yet, a fake. But how do we verify that we only made a single RPC call? Currently, it can be painful (the above API has a single chain, SomeClass->SomeResult. But if it's complex RPC call, as it is in my case, we can actually have a chain of 3-4).
My suggestion is to make it so that InvocationOnMock also records the return value of the invocation (whether it was a value from a fake, or a mock from a deep stub answer, etc.).
Then, when we do verify(), instead of returning a null value, we can actually return the recorded value. This would allow us to verify only 1 rpc was made, by doing this:
SomeClass someClass = spy(new SomeClass());
ToBeTested toTest = new ToBeTested(someClass);
toTest.doStuff();
verify(someClass).doSomething().makeRpcCall();
Remember, I'm talking about verification here - I'm not suggesting adding anything for mocking, only for verification of chained calls.
I can provide sample changes to the mockito codebase if it'll help explain what I'm saying, but I was hoping I could get buy-in before making any code changes.