Unit tests should be isolated, automated ( ie we don't need to do any prior-configuration for all tests to run at the click of a button ) and consistent in their results. For these reasons we should stub any external dependencies ( ie databases, webservices etc ) used by unit under test UUT ( with integration tests UUTs do use external dependencies ).But based on what criteria do we decide which internal dependencies called by UUT ( by internal dependencies I'm referring to code which is under our control and that doesn't communicate with any external systems ) also need to be stubbed and which don't need to be? Is perhaps the criteria that methods defined in the same class as UUT don't need to be stubbed, while methods defined in other classes should be, or ...?
Unit testing - External vs Internal dependencies
testing;unit testing
The criteria of Is it currently being tested by this specific unit test? If it's not being tested, yeah, stub it, mock it, fake it, set it to a hard known value, whatever. That way you know it's impact on the thing that's actually under test.Even though it's internal to your project and you control the source, it's external to the current thing you're testing. 