title: Stubbing the call of a super class method using Mockito(V 1.9.5)
body: <p>I am trying to test a method whom depending on some conditions will execute its code or its super class's one.
  Here is the code of the class and its parent:</p>
  
  <pre><code>public class ParentClass {
  
  public Object doStuff(Parameters parameters) {
      // do some business stuff
      return parentResult;
  }
  }
  </code></pre>
  
  <p>The inherited class's one:</p>
  
  <pre><code>public class InheritedClass extends ParentClass {
  
  @Override
  public Object doStuff(Parameters parameters) {
      if (parameters.getCondition()) {
          return super.doStuff(parameters);
      }
      //do some business stuff
      return inheritedResult;
  }
  }
  </code></pre>
  
  <p>So, when trying to test the case when the parameters.getCondition() is true, I have to mock the call on the super method and verify it.</p>
  
  <p>But when I do this (mocking the call for the super.doStuff()), I also mock the call to the InhertitedClass.doStuff().
  Here's the solution I tried:</p>
  
  <pre><code>@RunWith(MockitoJUnitRunner.class)
  public class InheritedClassTest {
  @Mock
  private Parameters parameters;
  
  @Spy
  private InheritedClass inherited = new InheritedClass();
  
  @Test
  public void testDoStuff(Object parameters) throws Exception {
      given(parameters.getCondition()).willReturn(true);
      doCallRealMethod().doReturn(value).when(inherited).doStuff(parameters);
  
      Mockito.verify(inherited, times(2)).doStuff(parameters);
  }
  }
  </code></pre>
  
  <p>I also tried this stubbing:</p>
  
  <pre><code>when(inherited.doStuff(parameters)).thenCallRealMethod().thenReturn(value);
  </code></pre>
  
  <p>and this one:</p>
  
  <pre><code>given(((ParentClass)inherited).doStuff(parameters)).willReturn(value);
  </code></pre>
  
  <p>In all this cases, the code of the parent class was really executed.
  So, I was wondering if there is any efficient way to mock the call of the super class method using mockito?</p>