title: PowerMock: stub methods from parent class
body: <p>I'm using PowerMock and I'd like to know how to keep all behavior of the child class, but stub <code>super</code> calls that may be overriden by the child.</p>
  
  <p>Say I have this class:</p>
  
  <pre><code>public class A {
      public String someMethod() {
          return "I don't want to see this value";
      }
  }
  </code></pre>
  
  <p>and a sub class:</p>
  
  <pre><code>public class B extends A {
      @Override
      public String someMethod() {
          return super.someMethod() + ", but I want to see this one";
      }
  }
  </code></pre>
  
  <p>How do I stub the call to <code>super.someMethod()</code>?</p>
  
  <p>I've tried</p>
  
  <pre><code>@Test
  public void test() {
      B spy = PowerMockito.spy(new B());
      PowerMockito.doReturn("value").when((A)spy).someMethod();
  
      assertEquals("value, but I want to see this one", spi.someMethod());
  }
  </code></pre>