How to Mock an @Inject Interface
<p>I have this Service Interface</p>

<pre><code>public interface ABC {
    public String getAbc();
}
</code></pre>

<p>And I have this controller that uses this Service</p>

<pre><code>public class Do {
    @Inject ABC abc;

    public String doAbc() {
       String a = abc.getAbc();
    }
}
</code></pre>

<p>In my Unit test, I want to be able to mock out this ABC and Not have to provide an actual implementation. Here is what works:</p>

<pre><code>public class TestDo {
   @Mock
   private Do do;

   @Mock
   private ABC abc;

   @Before
   public void init() {
       MockitoAnnotations.initMocks(this);
       do.abc = abc;
   }

   @Test
   public void testDo() {
       when(do.doAbc()).thenCallRealMethod();
       do.doAbc();
       assertSomething...
   }
}
</code></pre>

<p>But what I do not want to do is <code>do.abc = abc;</code>, from all my searches, in order to do @InjectMock, I need to provide a concrete class. Is there a way for me to use the interface but yet able to Inject the mocked interface into do without the need to exposed my ABC inject in Do Class? I want to make ABC a private variable, and still able to inject an interface through Mockito.</p>