title: How to Not Mock in JUnit
body: <p>We have a class in our code base called <code>LocationService</code> that basically does two things: makes HTTP calls to look up "Locations", and does a lot of work to map the information coming back into a usable format. For various reasons, primarily SRP, we would like to separate this class into two classes: <code>LocationLookupService</code> and <code>LocationFactoryService</code>. We've done that, and now the <code>LocationLookupService</code> will do its HTTP work and then call the Factory service. From a <code>src/main</code> perspective, this seems to work fine. However, the unit tests for the Lookup service are failing because the Factory isn't mocked - and I don't want it to be. I want the Lookup service to call the actual Factory without having to constantly rely on <code>doCallRealMethod</code> type mocks (which are dis-recommended). </p>
  
  <p>How can I correctly wire the actual Factory service bean into the Lookup bean at test time? I have tried various combinations of @Autowired, calling the constructor, and so on.</p>
  
  <pre><code>@Autowired private LocationFactoryService locationFactoryService;
  
  @InjectMocks private LocationLookupServiceImpl locationService;
  </code></pre>