title: Using the InjectMock annotation in Mockito with an object that hasn't been initialized
body: <p>I am attempting to use Mockito to unit test an Android application, specifically a fragment that gets initialized use newInstance(). I am having trouble injecting my Mock object into a private member variable of the object under test. All the examples I have seen show using <code>new()</code> instead of <code>newInstance()</code> and also show the <code>@InjectMocks</code> annotation on the same line as the initialization. Can I not declare the variable with the annotation but wait to initialize it later?</p>
  
  <p>I have: </p>
  
  <pre><code>public class  MyFragmentTest extends TestCase {
      @Mock (name="memberVariableName") private MyObject mMyObjectMock;
      @InjectMocks private MyFragment mFragment;
  
      @Override
      protected void setUp() throws Exception {
         super.setUp();
         // Initialize mock objects that are being injected
         MockitoAnnotations.initMocks(this);
  
         // Work around for a known issue with Mockito and Dexmaker
         System.setProperty("dexmaker.dexcache", getInstrumentation().getTargetContext().getCacheDir().getPath());
      }
  }
  </code></pre>