I have a basic question with regards to unit testing. I believe when you unit test , you basically test a unit of code and in case of java , we could treat each method as a unit of code. I believe when we unit test a method , all the calls to another method must be mocked in order to test the functionality of the method. Below is an exmaple. Please let me know if my understanding is correct.
I have classes A , B and C
Class A has method 1
Class B has method 1 and 2
Class C has method 1 which makes an external service call.
Class A.method 1-> Class B.method1 -> ClassB.method2 -> Class C.method 1 -> external soap service.
In the above scenario when I am unit testing Class A method 1 , should I mock the Class B.method1 response? Similarly when I am unit testing Class B.method1 , should mock Class B.method 2? I believe this would apply to other methods which are being called subsequently as well.