Package samples.finalmocking

Examples of samples.finalmocking.FinalDemo.say()


    FinalDemo tested = mock(FinalDemo.class);

    when(tested.say(argument)).thenReturn(expected);

    final String actual = tested.say(argument);

    verify(tested).say(argument);

    assertEquals("Expected and actual did not match", expected, actual);
  }
View Full Code Here


    FinalDemo spy = spy(tested);

    final String argument = "PowerMock";
    final String expected = "something";

    assertEquals("Hello " + argument, spy.say(argument));
    when(spy.say(argument)).thenReturn(expected);
    assertEquals(expected, spy.say(argument));
  }

  @Test(expected = ArrayStoreException.class)
View Full Code Here

    final String argument = "PowerMock";
    final String expected = "something";

    assertEquals("Hello " + argument, spy.say(argument));
    when(spy.say(argument)).thenReturn(expected);
    assertEquals(expected, spy.say(argument));
  }

  @Test(expected = ArrayStoreException.class)
  public void assertSpyingOnFinalVoidInstanceMethodWorks() throws Exception {
View Full Code Here

    final String argument = "PowerMock";
    final String expected = "something";

    assertEquals("Hello " + argument, spy.say(argument));
    when(spy.say(argument)).thenReturn(expected);
    assertEquals(expected, spy.say(argument));
  }

  @Test(expected = ArrayStoreException.class)
  public void assertSpyingOnFinalVoidInstanceMethodWorks() throws Exception {
    FinalDemo tested = new FinalDemo();
View Full Code Here

    @Test
    public void captorAnnotationWorks() throws Exception {
        final String expected = "testing";
        FinalDemo demo = mock(FinalDemo.class);
        demo.say(expected);

        verify(demo).say(captor.capture());
        assertEquals(expected, captor.getValue());
    }
View Full Code Here

    @Test
    public void mockingFinalClassesAndMethodsWorkWithTestNGAndEasyMock() throws Exception {
        final FinalDemo finalDemo = createMock(FinalDemo.class);

        expect(finalDemo.say("something")).andReturn("something else");

        replayAll();

        final String actual = finalDemo.say("something");
View Full Code Here

        expect(finalDemo.say("something")).andReturn("something else");

        replayAll();

        final String actual = finalDemo.say("something");

        verifyAll();

        assertEquals("something else", actual);
    }
View Full Code Here

  @Test
  public void testSay() throws Exception {
    FinalDemo tested = createMock(FinalDemo.class);
    String expected = "Hello altered World";
    expect(tested.say("hello")).andReturn("Hello altered World");
    replay(tested);

    String actual = tested.say("hello");

    verify(tested);
View Full Code Here

    FinalDemo tested = createMock(FinalDemo.class);
    String expected = "Hello altered World";
    expect(tested.say("hello")).andReturn("Hello altered World");
    replay(tested);

    String actual = tested.say("hello");

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

    // Should still be mocked by now.
View Full Code Here

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

    // Should still be mocked by now.
    try {
      tested.say("world");
      fail("Should throw AssertionError!");
    } catch (AssertionError e) {
      assertEquals("\n  Unexpected method call FinalDemo.say(\"world\"):", e.getMessage());
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.