title: Invoking a private method via JMockit to test result
body: <p>Am using JMockit 1.1 and all I want to do is invoke a private method and test the return value. However, I am having trouble understanding exactly how to do this from the <a href="http://jmockit.googlecode.com/svn/trunk/www/tutorial/BehaviorBasedTesting.html#deencapsulation">JMockit De-Encapsulation</a> example.</p>
  
  <p>The method I am trying to test is the private method in this class:</p>
  
  <pre><code>public class StringToTransaction {
     private List&lt;String&gt; parseTransactionString(final String input) {
        // .. processing
        return resultList;
     }
  }
  </code></pre>
  
  <p>And my test code is below.</p>
  
  <pre><code>@Test
  public void testParsingForCommas() {
     final StringToTransaction tested = new StringToTransaction();
     final List&lt;String&gt; expected = new ArrayList&lt;String&gt;();
     // Add expected strings list here..
     new Expectations() {
        {
           invoke(tested, "parseTransactionString", "blah blah");
           returns(expected);
        }
     };
  }
  </code></pre>
  
  <p>And the error I am getting is:</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>Perhaps I have misunderstood the whole API here, because I don't think I want to mock the class.. just test the result of calling the private method.</p>