Search in sources :

Example 1 with PrepareEverythingForTest

use of org.powermock.core.classloader.annotations.PrepareEverythingForTest in project powermock by powermock.

the class ExpectNewDemoUsingThePrepareEverythingAnnotationTest method testGetMessage.

@PrepareEverythingForTest
@Test
public void testGetMessage() throws Exception {
    ExpectNewDemo tested = new ExpectNewDemo();
    MyClass myClassMock = createMock(MyClass.class);
    expectNew(MyClass.class).andReturn(myClassMock);
    String expected = "Hello altered World";
    expect(myClassMock.getMessage()).andReturn("Hello altered World");
    replayAll();
    String actual = tested.getMessage();
    verifyAll();
    assertEquals("Expected and actual did not match", expected, actual);
}
Also used : ExpectNewDemo(samples.expectnew.ExpectNewDemo) MyClass(samples.newmocking.MyClass) Test(org.junit.Test) PrepareEverythingForTest(org.powermock.core.classloader.annotations.PrepareEverythingForTest) PrepareEverythingForTest(org.powermock.core.classloader.annotations.PrepareEverythingForTest)

Aggregations

Test (org.junit.Test)1 PrepareEverythingForTest (org.powermock.core.classloader.annotations.PrepareEverythingForTest)1 ExpectNewDemo (samples.expectnew.ExpectNewDemo)1 MyClass (samples.newmocking.MyClass)1