Search in sources :

Example 6 with VerificationInOrderFailure

use of org.mockito.exceptions.verification.VerificationInOrderFailure in project mockito by mockito.

the class SelectedMocksInOrderVerificationTest method shouldFailVerificationForMockOne.

@Test
public void shouldFailVerificationForMockOne() {
    InOrder inOrder = inOrder(mockOne);
    inOrder.verify(mockOne).simpleMethod(1);
    try {
        inOrder.verify(mockOne).differentMethod();
        fail();
    } catch (VerificationInOrderFailure e) {
    }
}
Also used : InOrder(org.mockito.InOrder) VerificationInOrderFailure(org.mockito.exceptions.verification.VerificationInOrderFailure) Test(org.junit.Test)

Example 7 with VerificationInOrderFailure

use of org.mockito.exceptions.verification.VerificationInOrderFailure in project mockito by mockito.

the class SelectedMocksInOrderVerificationTest method shouldThrowTooManyInvocationsForMockTwo.

@Test
public void shouldThrowTooManyInvocationsForMockTwo() {
    InOrder inOrder = inOrder(mockTwo);
    try {
        inOrder.verify(mockTwo, times(2)).simpleMethod(2);
        fail();
    } catch (VerificationInOrderFailure e) {
    }
}
Also used : InOrder(org.mockito.InOrder) VerificationInOrderFailure(org.mockito.exceptions.verification.VerificationInOrderFailure) Test(org.junit.Test)

Example 8 with VerificationInOrderFailure

use of org.mockito.exceptions.verification.VerificationInOrderFailure in project mockito by mockito.

the class SelectedMocksInOrderVerificationTest method shouldFailVerificationForMockOneBecauseOfWrongOrder.

@Test
public void shouldFailVerificationForMockOneBecauseOfWrongOrder() {
    InOrder inOrder = inOrder(mockOne);
    inOrder.verify(mockOne).simpleMethod(4);
    try {
        inOrder.verify(mockOne).simpleMethod(1);
        fail();
    } catch (VerificationInOrderFailure e) {
    }
}
Also used : InOrder(org.mockito.InOrder) VerificationInOrderFailure(org.mockito.exceptions.verification.VerificationInOrderFailure) Test(org.junit.Test)

Example 9 with VerificationInOrderFailure

use of org.mockito.exceptions.verification.VerificationInOrderFailure in project mockito by mockito.

the class SelectedMocksInOrderVerificationTest method shouldThrowNoMoreInvocationsForMockTwo.

@Test
public void shouldThrowNoMoreInvocationsForMockTwo() {
    InOrder inOrder = inOrder(mockTwo);
    try {
        inOrder.verify(mockTwo, times(2)).simpleMethod(2);
        fail();
    } catch (VerificationInOrderFailure e) {
    }
}
Also used : InOrder(org.mockito.InOrder) VerificationInOrderFailure(org.mockito.exceptions.verification.VerificationInOrderFailure) Test(org.junit.Test)

Example 10 with VerificationInOrderFailure

use of org.mockito.exceptions.verification.VerificationInOrderFailure in project mockito by mockito.

the class NoMoreInteractionsTest method noMoreInteractionsInOrderExceptionMessageShouldDescribeMock.

@Test
public void noMoreInteractionsInOrderExceptionMessageShouldDescribeMock() {
    //given
    NoMoreInteractions n = new NoMoreInteractions();
    IMethods mock = mock(IMethods.class, "a mock");
    Invocation i = new InvocationBuilder().mock(mock).toInvocation();
    try {
        //when
        n.verifyInOrder(new VerificationDataInOrderImpl(context, asList(i), null));
        //then
        fail();
    } catch (VerificationInOrderFailure e) {
        Assertions.assertThat(e.toString()).contains(mock.toString());
    }
}
Also used : Invocation(org.mockito.invocation.Invocation) IMethods(org.mockitousage.IMethods) InvocationBuilder(org.mockito.internal.invocation.InvocationBuilder) VerificationDataInOrderImpl(org.mockito.internal.verification.api.VerificationDataInOrderImpl) VerificationInOrderFailure(org.mockito.exceptions.verification.VerificationInOrderFailure) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)15 VerificationInOrderFailure (org.mockito.exceptions.verification.VerificationInOrderFailure)15 InOrder (org.mockito.InOrder)12 InvocationBuilder (org.mockito.internal.invocation.InvocationBuilder)3 VerificationDataInOrderImpl (org.mockito.internal.verification.api.VerificationDataInOrderImpl)3 Invocation (org.mockito.invocation.Invocation)3 IMethods (org.mockitousage.IMethods)1