Recently, I've been reading a lot of articles (mostly from J.B. Rainsberger) about contract and collaborative tests. In order to get it into it, I've started a small project.
From my understanding, the responsiblity of a contract test is to ensure that an implementation respects its interface inherent contract. In other words, it encourages the Liskov substitution principle.
Mocking an objects collaborator is, basically, all about making assumptions about it. Now, what happens if these assumptions change? If I mock the collaborator using Mockito like this (which comes to the same thing as stubbing):
when(collaborator.doSomething(someArgument)).thenReturn(someValue);
I won't be able to notice the changes when I'll modify the collaborators interface (that is, its contract).
So here's my question : Is it right that when faking a collaborator which provides indirect inputs to a system under test, one should use stubs in order to prevent unnoticed interface / contract changes?
Here are some links that I've already checked:
removing-the-integration-test-scam-understanding-collaboration-and-contract
writing contract tests in java differently
I hope I'm clear enough, if not, I'll do my best to make this more transparent. Thanks to you all in advance.