In automated tests, mock out non-intrinsic dependencies whenever possible

Unless you are writing a full, end-to-end integration test, mock out any significant calls to other services or classes where the implementation is assumed to be correct for the purposes of your test. Ideally, use dependency injection (e.g. Spring framework) to make it easy to switch from mocks to the real…