Package samples.partialmocking

Examples of samples.partialmocking.MockSelfDemoWithSubClass


@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);
  }
View Full Code Here

TOP

Related Classes of samples.partialmocking.MockSelfDemoWithSubClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.