When you need to test an object using collaborators and want to be sure that the tested behavior is provided only by the code in the…