title: Mockito: inject a class mock into a private interface field
body: <p>I'm using Mockito 1.9.5 to do some unit testing. I'm trying to inject a concrete class mock into a class that has a private interface field. Here's an example:</p>
  
  <p><strong>Class I'm testing</strong></p>
  
  <pre><code>@Component
  public class Service {
  
      @Autowired 
      private iHelper helper;
  
      public void doSomething() {
          helper.helpMeOut();
      }
  }
  </code></pre>
  
  <p><strong>My test for this class</strong></p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  public class ServiceTest {
  
      @Mock
      private iHelper helper;
  
      @InjectMocks
      private Service service;
  
      @Before
      public void setup() {
          service = new Service();
      }
  
      @Test
      public void testStuff() {
          doNothing().when(helper).helpMeOut();
          service.doSomething();
      }
  }
  </code></pre>
  
  <p>This code throws a NullPointerException when trying to call helper.helpMeOut() in doSomething(). I debugged and found that helper was null when running the test. I also tried changing iHelper to the concrete class Helper, and the same issue happened.</p>
  
  <p>Any suggestions? How can I get Mockito to correctly inject a mock into an interface private field?</p>