title: Can not mock the private method with mockito
body: <p>I am trying to mock a private method with power mockito, after reading this post I got some idea and I followed the same structure:</p>
  
  <p><a href="https://stackoverflow.com/questions/28121177/mock-private-method-using-powermockito">example </a></p>
  
  <p>here is my class:</p>
  
  <pre><code>public class test(){
    private long verifyMarketEligibilityAndGetOfferDeliveryCalendar(long id)
    {
      some lins of code for connectiong to db
    }
    public long createOffer(long id){
  
      return verifyMarketEligibilityAndGetOfferDeliveryCalendar(id);
    }
  
  }
  </code></pre>
  
  <p>And here is my mock test: </p>
  
  <pre><code>test classUnderTest = PowerMockito.spy(new test());
          PowerMockito.doReturn(10).when(classUnderTest,
                  "verifyMarketEligibilityAndGetOfferDeliveryCalendar", 10l);
          classUnderTest.createOffer(10);
  </code></pre>
  
  <p>Now I expect that after calling createoffer, verifyMarketEligibilityAndGetOfferDeliveryCalendar does not invoke and instead number 10 returns but for some reason program start executing the verifyMarketEligibilityAndGetOfferDeliveryCalendar class and consequently db related code .</p>
  
  <p>Can anyone help?  </p>