title: EasyMock - mocking abstract methods inherited from an interface
body: <p>I'm having some difficulty with EasyMock (3.1) class mocking.  This is supposedly suitable to mock partial class implementations, which, I figured, should be ideal to unit test abstract base classes while mocking out the missing method(s).  Here's the pattern - an instantly recognizable classic...</p>
  
  <pre><code>public interface Interface {
      public void intfMethod();
  }
  
  public abstract class AbstractBase implements Interface {
      public void otherMethod() {
          // do some stuff we need to test...
          intfMethod();
      }
  }
  </code></pre>
  
  <p>Now the test:</p>
  
  <pre><code>public class TestAbstractBase {
      AbstractBase testInstance;
  
      @Before
      public void setUp() {
          testInstance =
              createMockBuilder(AbstractBase.class).addMockedMethod("intfMethod").createMock();
      }
      @Test
      public void testOtherMethod() {
          testInstance.intfMethod();  // expect this to be invoked on the mock...
          replay(testInstance);
          testInstance.otherMethod();
          verify(testInstance);
      }
  }
  </code></pre>
  
  <p>EasyMock doesn't seem to like this.  It throws:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Method not found (or private): intfMethod
      at org.easymock.internal.MockBuilder.addMockedMethod(MockBuilder.java:78)
      at TestAbstractBase.setUp(TestAbstractBase.java:19)
  </code></pre>
  
  <p>Any ideas?  I found a <a href="https://stackoverflow.com/questions/6412988/how-do-i-mock-a-method-inherited-from-an-abstract-class-with-easymock">related question</a> but it doesn't really do justice to its title...</p>