title: Why can't I use @InjectMocks field matching when running with PowerMockRunner?
body: <p>I've run into an issue in which the field injection matching for Mockito's <code>@Mock</code> annotation for <code>@InjectMocks</code> is not working in the case where there are 2 <code>@Mock</code>s of the same type.  I've used the <code>@Mock (name = "name_of_var")</code> syntax as well, but it still failed...</p>
  
  <p>Here is the class under test:</p>
  
  <pre><code>    import java.util.Date;
      public class Parent{
  
      private Date dateA;
      private Date dateB;
  
      public void setDateA(Date _dateA){
         dateA = _dateA;
      }
  
      public void setDateB(Date _dateB){
         dateB = _dateB;
      }
  
      public Date getDateA(){
         return dateA;
      }
  
      public Date getDateB(){
         return dateB;
      }
  </code></pre>
  
  <p>Here is the test itself:</p>
  
  <pre><code>    @RunWith(PowerMockRunner.class)
      @PrepareForTest({System.class, Parent.class})
      public class testParent{
  
      @Mock (name = "dateB")  private Date someOtherDate;
      @Mock (name = "dateA")  private Date someDate;    
  
      @InjectMocks Parent p;
  
      @Before
      public void setup(){
          Mockito.when(someOtherDate.getTime()).thenReturn(500l);
          PowerMockito.mockStatic(System.class);
          PowerMockito.when(System.currentTimeMillis()).thenReturn(2000l);
      }
  
      @Test
      public void testGetDateAGetTimeShouldReturn1000() {
          Mockito.when(someDate.getTime()).thenReturn(1000l);
          Date result = p.getDateA();
          assertEquals(1000l, result.getTime());
      }
  
      @Test
      public void testGetDateBGetTimeShouldReturn500() {
          Date result = p.getDateB();
          assertEquals(500l, result.getTime());   
      }
  </code></pre>
  
  <p>When tested, both <code>assertEquals</code> cause a <code>NullPointerException</code> due to the fact that the <code>@InjectMocks</code> did not work.</p>
  
  <p>Now, when I replaced <code>@RunWith(PowerMockRunner.class)</code> with <code>@RunWith(MockitoJUnitRunner.class)</code>, it WORKS just fine.</p>
  
  <p>Also, if I had just defined 1 <code>Date</code> variable ( say, <code>dateA</code> ) in <code>Parent.java</code> and a matching mock to inject in <code>ParentTest</code>, it would inject just fine using <code>PowerMockRunner.class</code>.</p>
  
  <p>The reason I must run with PowerMockRunner.class is because I must be able to mock static functions as well as constructors.  </p>
  
  <p>I am running with Junit4.12, Mockito-all-1.10.19, and PowerMock-mockito-1.6.2-full.</p>
  
  <p>Does anyone see the cause of why it does not inject properly with <code>PowerMockRunner.class</code>?  Is there a workaround for this while running with <code>PowerMockRunner.class</code>?</p>