title: Mock inherited method in Mockito Java
body: <p>My class structure is as follows: </p>
  
  <pre><code>public class MyParentClass {
  
      void doSomethingParent() {
          System.out.println("something in parent");
      }
  }
  
  public class MyClass extends MyParentClass {
  
      protected String createDummyRequest(Holder myHolder) {
          //...
          super.doSomethingParent();//I want to avoid this
          //...
          callingDB();
          return "processedOutput";
      }
  
      private void callingDB() {
          System.out.println("Calling to DB");
      }
  }
  </code></pre>
  
  <p>Then my unit test:</p>
  
  <pre><code>public class UnitTest {
  
      public void testCreateDummyRequest() {
          //create my mock holder
          Holder mockHolder = new Holder();
  
          MyClass mockObj = Mockito.mock(MyClass.class);
          //mock doSomethingParent()
          //mock callingDB()
  
          //as mockObj is a fully mock, but I need to run my real method
          //Mockito.when(mockObj.createDummyRequest(mockHolder)).thenCallRealMethod();
          mockObj.createDummyRequest(mockHolder);
          //Problem: doSomethingParent() is getting called though I have mocked it
      }
  }
  </code></pre>
  
  <p>How do I prevent the calling of the super.doSomethingParent() in my method? (method which I am writing my test)</p>