Search in sources :

Example 1 with InOrderContext

use of org.mockito.internal.verification.api.InOrderContext in project mockito by mockito.

the class AtLeastXNumberOfInvocationsCheckerTest method shouldReportTooLittleInvocationsInOrder.

@Test
public void shouldReportTooLittleInvocationsInOrder() {
    InOrderContext context = new InOrderContextImpl();
    //given
    Invocation invocation = new InvocationBuilder().simpleMethod().toInvocation();
    Invocation invocationTwo = new InvocationBuilder().differentMethod().toInvocation();
    exception.expect(VerificationInOrderFailure.class);
    exception.expectMessage("iMethods.simpleMethod()");
    exception.expectMessage("Wanted *at least* 2 times");
    exception.expectMessage("But was 1 time");
    //when
    checkAtLeastNumberOfInvocations(asList(invocation, invocationTwo), new InvocationMatcher(invocation), 2, context);
}
Also used : InOrderContextImpl(org.mockito.internal.verification.InOrderContextImpl) Invocation(org.mockito.invocation.Invocation) InvocationMatcher(org.mockito.internal.invocation.InvocationMatcher) InvocationBuilder(org.mockito.internal.invocation.InvocationBuilder) InOrderContext(org.mockito.internal.verification.api.InOrderContext) Test(org.junit.Test)

Example 2 with InOrderContext

use of org.mockito.internal.verification.api.InOrderContext in project mockito by mockito.

the class AtLeastXNumberOfInvocationsCheckerTest method shouldMarkActualInvocationsAsVerifiedInOrder.

@Test
public void shouldMarkActualInvocationsAsVerifiedInOrder() {
    InOrderContext context = new InOrderContextImpl();
    //given
    Invocation invocation = new InvocationBuilder().simpleMethod().toInvocation();
    Invocation invocationTwo = new InvocationBuilder().differentMethod().toInvocation();
    //when
    checkAtLeastNumberOfInvocations(asList(invocation, invocationTwo), new InvocationMatcher(invocation), 1, context);
    //then
    assertThat(invocation.isVerified()).isTrue();
}
Also used : InOrderContextImpl(org.mockito.internal.verification.InOrderContextImpl) Invocation(org.mockito.invocation.Invocation) InvocationMatcher(org.mockito.internal.invocation.InvocationMatcher) InvocationBuilder(org.mockito.internal.invocation.InvocationBuilder) InOrderContext(org.mockito.internal.verification.api.InOrderContext) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 InvocationBuilder (org.mockito.internal.invocation.InvocationBuilder)2 InvocationMatcher (org.mockito.internal.invocation.InvocationMatcher)2 InOrderContextImpl (org.mockito.internal.verification.InOrderContextImpl)2 InOrderContext (org.mockito.internal.verification.api.InOrderContext)2 Invocation (org.mockito.invocation.Invocation)2