Package samples.newmocking

Examples of samples.newmocking.MyClass


  @Test
  public void testGetMessageWithArgument() throws Exception {
    ExpectNewDemo tested = new ExpectNewDemo();

    MyClass myClassMock = mock(MyClass.class);
    whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock);

    String expected = "Hello altered World";
    when(myClassMock.getMessage("test")).thenReturn("Hello altered World");

    String actual = tested.getMessageWithArgument();

    verify(myClassMock).getMessage("test");
    verifyNew(MyClass.class).withNoArguments();
View Full Code Here


  @Test
  public void testInvokeVoidMethod() throws Exception {
    ExpectNewDemo tested = new ExpectNewDemo();

    MyClass myClassMock = mock(MyClass.class);
    whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock);

    doNothing().when(myClassMock).voidMethod();

    tested.invokeVoidMethod();
View Full Code Here

  @Test
  public void testMultipleNew() throws Exception {
    ExpectNewDemo tested = new ExpectNewDemo();

    MyClass myClassMock = mock(MyClass.class);

    whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock);

    when(myClassMock.getMessage()).thenReturn("Hello");

    final String actual = tested.multipleNew();

    verify(myClassMock, times(2)).getMessage();
    verifyNew(MyClass.class, times(2)).withNoArguments();
View Full Code Here

  @Test
  public void testSimpleMultipleNew() throws Exception {
    ExpectNewDemo tested = new ExpectNewDemo();

    MyClass myClassMock = mock(MyClass.class);

    whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock);

    tested.simpleMultipleNew();
View Full Code Here

  @Test
  public void testSimpleMultipleNew_tooManyTimesExpected() throws Exception {
    ExpectNewDemo tested = new ExpectNewDemo();

    MyClass myClassMock = mock(MyClass.class);

    whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock);

    tested.simpleMultipleNew();
View Full Code Here

  @Test
  public void testSimpleMultipleNew_tooFewTimesExpected() throws Exception {
    ExpectNewDemo tested = new ExpectNewDemo();

    MyClass myClassMock1 = mock(MyClass.class);

    whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock1);

    tested.simpleMultipleNew();
    try {
View Full Code Here

   */
  @Test
  public void testSimpleMultipleNewPrivate_tooFewTimesExpected() throws Exception {
    ExpectNewDemo tested = new ExpectNewDemo();

    MyClass myClassMock1 = mock(MyClass.class);

    whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock1);

    Whitebox.invokeMethod(tested, "simpleMultipleNewPrivate");

View Full Code Here

  @Test
  public void testSimpleMultipleNewPrivate_ok() throws Exception {
    ExpectNewDemo tested = new ExpectNewDemo();

    MyClass myClassMock1 = mock(MyClass.class);

    whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock1);

    Whitebox.invokeMethod(tested, "simpleMultipleNewPrivate");
View Full Code Here

  @Test
  public void testSimpleSingleNew_withOnce() throws Exception {
    ExpectNewDemo tested = new ExpectNewDemo();

    MyClass myClassMock1 = mock(MyClass.class);

    whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock1);

    tested.simpleSingleNew();
View Full Code Here

  @Test
  public void testSimpleSingleNew_withAtLeastOnce() throws Exception {
    ExpectNewDemo tested = new ExpectNewDemo();

    MyClass myClassMock1 = mock(MyClass.class);

    whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock1);

    tested.simpleSingleNew();
View Full Code Here

TOP

Related Classes of samples.newmocking.MyClass

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.