title: Google Guice + Mockito
body: <p><code>Class A</code> depends on <code>class B</code>, <code>class B</code> depends on <code>class C</code>.</p>
  <p>I'm trying to test <code>class A</code>, for this I create a <code>B-mock</code>, and bind it with <code>class B</code>:</p>
  <pre><code>injector =
       Guice.createInjector (
           new AbstractModule () {
               @Override
               protected void configure () {
                   bind(B.class).toInstance(Mockito.mock(B.class));
               }
           }
       );
  </code></pre>
  <p>It would seem that since <code>B</code> is a mock, then an object of <code>class C</code> is not needed either. But google guice is still trying to create it for some reason using <code>new</code>.
  I know this because I put <code>System.out(&quot;C conctructor&quot;)</code> in the <code>C class</code> constructor, and I see this output in the tests.</p>
  <p>One solution is to use its interface instead of <code>class C</code>. But this is strange behavior anyway.</p>
  <p>How else can you get around this situation?</p>