title: How do I use Mockito to mock a protected method?
body: <p>I’m using Mockito 1.9.5.  How do I mock what is coming back from a protected method?  I have this protected method …</p>
  
  <pre><code>protected JSONObject myMethod(final String param1, final String param2)
  {
  …
  }
  </code></pre>
  
  <p>However, when I attempt to do this in JUnit:</p>
  
  <pre><code>    final MyService mymock = Mockito.mock(MyService.class, Mockito.CALLS_REAL_METHODS);        
      final String pararm1 = “param1”;
      Mockito.doReturn(myData).when(mymock).myMethod(param1, param2);
  </code></pre>
  
  <p>On the last line, I get a compilation error “The method ‘myMethod’ is not visible.”  How do I use Mockito to mock protected methods?  I’m open to upgrading my version if that’s the answer.</p>