Java 类org.mockito.exceptions.verification.TooLittleActualInvocations 实例源码

项目:astor    文件:DescriptiveMessagesWhenTimesXVerificationFailsTest.java   
@Test
public void shouldVerifyActualNumberOfInvocationsSmallerThanWanted() throws Exception {
    mock.clear();
    mock.clear();
    mock.clear();

    Mockito.verify(mock, times(3)).clear();
    try {
        Mockito.verify(mock, times(100)).clear();
        fail();
    } catch (TooLittleActualInvocations e) {
        assertContains("mock.clear();", e.getMessage());
        assertContains("Wanted 100 times", e.getMessage());
        assertContains("was 3", e.getMessage());
    }
}
项目:astor    文件:DescriptiveMessagesWhenTimesXVerificationFailsTest.java   
@Test
public void shouldVerifyActualNumberOfInvocationsSmallerThanWanted() throws Exception {
    mock.clear();
    mock.clear();
    mock.clear();

    Mockito.verify(mock, times(3)).clear();
    try {
        Mockito.verify(mock, times(100)).clear();
        fail();
    } catch (TooLittleActualInvocations e) {
        assertContains("mock.clear();", e.getMessage());
        assertContains("Wanted 100 times", e.getMessage());
        assertContains("was 3", e.getMessage());
    }
}
项目:powermock    文件:MockStaticTest.java   
@Test(expected = TooLittleActualInvocations.class)
public void testMockStaticIncorrectTimes() throws Exception {
    mockStatic(StaticService.class);
    assertNull(StaticService.say("hello"));
    assertNull(StaticService.say("hello"));

    // Verification is done in two steps using static methods.
    verifyStatic(times(3));
    StaticService.say("hello");
}
项目:powermock    文件:MockStaticTest.java   
@Test(expected = TooLittleActualInvocations.class)
public void testMockStaticIncorrectTimes() throws Exception {
    mockStatic(StaticService.class);
    assertNull(StaticService.say("hello"));
    assertNull(StaticService.say("hello"));

    // Verification is done in two steps using static methods.
    verifyStatic(times(3));
    StaticService.say("hello");
}
项目:powermock    文件:MockStaticTest.java   
@Test(expected = TooLittleActualInvocations.class)
public void testMockStaticIncorrectTimes() throws Exception {
    mockStatic(StaticService.class);
    assertNull(StaticService.say("hello"));
    assertNull(StaticService.say("hello"));

    // Verification is done in two steps using static methods.
    verifyStatic(times(3));
    StaticService.say("hello");
}
项目:powermock    文件:MockStaticTest.java   
@Test(expected = TooLittleActualInvocations.class)
public void testMockStaticIncorrectTimes() throws Exception {
    mockStatic(StaticService.class);
    assertNull(StaticService.say("hello"));
    assertNull(StaticService.say("hello"));

    // Verification is done in two steps using static methods.
    verifyStatic(times(3));
    StaticService.say("hello");
}
项目:astor    文件:ExactNumberOfTimesVerificationTest.java   
@Test
public void shouldDetectTooLittleActualInvocations() throws Exception {
    mock.clear();
    mock.clear();

    verify(mock, times(2)).clear();
    try {
        verify(mock, times(100)).clear();
        fail();
    } catch (TooLittleActualInvocations e) {
        assertContains("Wanted 100 times", e.getMessage());
        assertContains("was 2", e.getMessage());
    }
}
项目:astor    文件:SpyingOnRealObjectsTest.java   
@Test
public void shouldVerifyNumberOfTimesAndFail() {
    spy.add("one");
    spy.add("one");

    try {
        verify(spy, times(3)).add("one");
        fail();
    } catch (TooLittleActualInvocations e) {}
}
项目:astor    文件:ExactNumberOfTimesVerificationTest.java   
@Test
public void shouldDetectTooLittleActualInvocations() throws Exception {
    mock.clear();
    mock.clear();

    verify(mock, times(2)).clear();
    try {
        verify(mock, times(100)).clear();
        fail();
    } catch (TooLittleActualInvocations e) {
        assertContains("Wanted 100 times", e.getMessage());
        assertContains("was 2", e.getMessage());
    }
}
项目:astor    文件:SpyingOnRealObjectsTest.java   
@Test
public void shouldVerifyNumberOfTimesAndFail() {
    spy.add("one");
    spy.add("one");

    try {
        verify(spy, times(3)).add("one");
        fail();
    } catch (TooLittleActualInvocations e) {}
}
项目:astor    文件:Reporter.java   
public void tooLittleActualInvocations(Discrepancy discrepancy, PrintableInvocation wanted, Location lastActualLocation) {
    String message = createTooLittleInvocationsMessage(discrepancy, wanted, lastActualLocation);

    throw new TooLittleActualInvocations(message);
}
项目:astor    文件:ReporterTest.java   
@Test(expected=TooLittleActualInvocations.class)
public void shouldLetPassingNullLastActualStackTrace() throws Exception {
    new Reporter().tooLittleActualInvocations(new Discrepancy(1, 2), new InvocationBuilder().toInvocation(), null);
}
项目:astor    文件:Reporter.java   
public void tooLittleActualInvocations(org.mockito.internal.reporting.Discrepancy discrepancy, DescribedInvocation wanted, Location lastActualLocation) {
    String message = createTooLittleInvocationsMessage(discrepancy, wanted, lastActualLocation);

    throw new TooLittleActualInvocations(message);
}
项目:astor    文件:ReporterTest.java   
@Test(expected=TooLittleActualInvocations.class)
public void shouldLetPassingNullLastActualStackTrace() throws Exception {
    new Reporter().tooLittleActualInvocations(new org.mockito.internal.reporting.Discrepancy(1, 2), new InvocationBuilder().toInvocation(), null);
}