Package samples.newmocking

Examples of samples.newmocking.StupidNew


@PrepareForTest( { MyClass.class, StupidNew.class })
public class StupidNewTest {

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


    assertEquals("Expected and actual did not match", expected, actual);
  }

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

    assertEquals("Expected and actual did not match", expected, actual);
  }

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

TOP

Related Classes of samples.newmocking.StupidNew

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.