title: How does Mockito @InjectMocks work?
body: <p>Here's my question:</p>
  
  <p>I have several web services classes to test that all inherit their methods from a generic service. Rather than write a unit test for each, I figure I can break the test suite down by functional areas (i.e. three groups of test methods, each relying on a different underlying DAO method call).</p>
  
  <p>What I propose to do is:</p>
  
  <pre><code>@Mock StateDAO mockedStateDao;
  @Mock CountyDAO mockedCountyDao;
  @Mock VisitorDAO mockedVisitorDao;
  </code></pre>
  
  <p>then  call:</p>
  
  <pre><code>@InjectMocks CountyServiceImpl&lt;County&gt; countyService = new CountyServiceImpl&lt;County&gt;();
  @InjectMocks StateServiceImpl&lt;State&gt; stateService = new StateServiceImpl&lt;State&gt;();
  @InjectMocks VisitorServiceImpl&lt;Visitor&gt; visitorService = new VisitorServiceImpl&lt;Visitor&gt;();
  </code></pre>
  
  <p>How can I be sure that each mockedDAO will be injected into the correct service?
  Would it be easier to autowire all three (rather than use @InjectMocks)?</p>
  
  <p>I'm using Spring, Hibernate, and Mockito...</p>