Search in sources :

Example 1 with StupidNew

use of samples.newmocking.StupidNew in project powermock by powermock.

the class StupidNewTest method testGetMessageWithArgument.

@Test
public void testGetMessageWithArgument() throws Exception {
    StupidNew tested = new StupidNew();
    MyClass myClassMock = createMockAndExpectNew(MyClass.class);
    String expected = "Hello altered World";
    expect(myClassMock.getMessage("test")).andReturn("Hello altered World");
    replay(myClassMock, MyClass.class);
    String actual = tested.getMessageWithArgument();
    verify(myClassMock, MyClass.class);
    assertEquals("Expected and actual did not match", expected, actual);
}
Also used : MyClass(samples.newmocking.MyClass) StupidNew(samples.newmocking.StupidNew) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with StupidNew

use of samples.newmocking.StupidNew in project powermock by powermock.

the class StupidNewTest method testGetMessage.

@Test
public void testGetMessage() throws Exception {
    StupidNew tested = new StupidNew();
    MyClass myClassMock = createMockAndExpectNew(MyClass.class);
    String expected = "Hello altered World";
    expect(myClassMock.getMessage()).andReturn("Hello altered World");
    replay(myClassMock, MyClass.class);
    String actual = tested.getMessage();
    verify(myClassMock, MyClass.class);
    assertEquals("Expected and actual did not match", expected, actual);
}
Also used : MyClass(samples.newmocking.MyClass) StupidNew(samples.newmocking.StupidNew) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with StupidNew

use of samples.newmocking.StupidNew in project powermock by powermock.

the class StupidNewTest method testInvokeVoidMethod.

@Test
public void testInvokeVoidMethod() throws Exception {
    StupidNew tested = new StupidNew();
    MyClass myClassMock = createMockAndExpectNew(MyClass.class);
    myClassMock.voidMethod();
    expectLastCall().times(1);
    replay(myClassMock, MyClass.class);
    tested.invokeVoidMethod();
    verify(myClassMock, MyClass.class);
}
Also used : MyClass(samples.newmocking.MyClass) StupidNew(samples.newmocking.StupidNew) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 MyClass (samples.newmocking.MyClass)3 StupidNew (samples.newmocking.StupidNew)3