title: Mocking a private method in an Expectations block causes "IllegalStateException: Missing invocation to mocked type at this point"
body: <p>I have a JUnit test that uses a JMockit <code>Expectations</code> block:</p>
  
  <pre><code>@Tested
  private MyTestedClass myTestedClass;
  
  @Injectable
  private MyOtherClass myOtherClass;
  
  @Test
  public void publicBooleanMethodTest() {
  
      new Expectations() {{
          invoke(myOtherClass, "privateMethod");
          result = true;
      }};
  
      myTestedClass.run(); // Calls myOtherClass.privateMethod();
  } 
  </code></pre>
  
  <p>However, this results in the following error:</p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: Missing invocation to mocked type at this point; please make sure such invocations appear only after the declaration of a suitable mock field or parameter</p>
  </blockquote>
  
  <p>As you can see, <code>myClass</code> is mocked via <code>@Injectable</code>, so I'm not sure why the error is happening. I have also found that if I change the scope of <code>privateMethod()</code> to public, everything works.</p>
  
  <p>What is going on and how can I fix this? It worked fine in JMockit 1.22, but now fails in JMockit 1.23 and greater.</p>