@PrepareForTest(MockSelfDemoWithSubClass.class)
public class MockSelfDemoWithSubClassTest {
@Test
public void testMockPartialMethodInChildClass() throws Exception {
MockSelfDemoWithSubClass tested = createPartialMock(
MockSelfDemoWithSubClass.class, "getAMessage",
"getInternalMessage");
final String getAMessageMock = "Hello ";
final String getInternalMessageMock = "World!";
final String expected = getInternalMessageMock + getAMessageMock;
expect(tested.getAMessage()).andReturn(getAMessageMock);
expectPrivate(tested, "getInternalMessage").andReturn(
getInternalMessageMock);
replay(tested);
String actual = tested.getMessage();
verify(tested);
assertEquals(expected, actual);
}