org.mockito.exceptions.verification.VerificationInOrderFailure Java Examples
The following examples show how to use
org.mockito.exceptions.verification.VerificationInOrderFailure.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DescriptiveMessagesOnVerificationInOrderErrorsTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void shouldPrintMethodThatWasNotInvoked() { inOrder.verify(one).simpleMethod(1); inOrder.verify(one).simpleMethod(11); inOrder.verify(two, times(2)).simpleMethod(2); inOrder.verify(three).simpleMethod(3); try { inOrder.verify(three).simpleMethod(999); fail(); } catch (VerificationInOrderFailure e) { String actualMessage = e.getMessage(); String expectedMessage = "\n" + "Verification in order failure" + "\n" + "Wanted but not invoked:" + "\n" + "iMethods.simpleMethod(999);"; assertContains(expectedMessage, actualMessage); } }
Example #2
Source File: DescriptiveMessagesOnVerificationInOrderErrorsTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void shouldPrintMethodThatWasNotInvoked() { inOrder.verify(one).simpleMethod(1); inOrder.verify(one).simpleMethod(11); inOrder.verify(two, times(2)).simpleMethod(2); inOrder.verify(three).simpleMethod(3); try { inOrder.verify(three).simpleMethod(999); fail(); } catch (VerificationInOrderFailure e) { String actualMessage = e.getMessage(); String expectedMessage = "\n" + "Verification in order failure" + "\n" + "Wanted but not invoked:" + "\n" + "iMethods.simpleMethod(999);"; assertContains(expectedMessage, actualMessage); } }
Example #3
Source File: ExactNumberOfTimesVerificationTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void shouldAllowVerifyingInteractionNeverHappenedInOrder() throws Exception { mock.add("one"); mock.add("two"); InOrder inOrder = inOrder(mock); inOrder.verify(mock, never()).add("xxx"); inOrder.verify(mock).add("one"); inOrder.verify(mock, never()).add("one"); try { inOrder.verify(mock, never()).add("two"); fail(); } catch (VerificationInOrderFailure e) {} }
Example #4
Source File: VerificationInOrderTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void shouldVerifyInOrderUsingMatcher() { mockOne.simpleMethod(1); mockOne.simpleMethod(2); mockTwo.differentMethod(); mockOne.simpleMethod(3); mockOne.simpleMethod(4); verify(mockOne, times(4)).simpleMethod(anyInt()); inOrder.verify(mockOne, times(2)).simpleMethod(anyInt()); inOrder.verify(mockTwo).differentMethod(); inOrder.verify(mockOne, times(2)).simpleMethod(anyInt()); try { inOrder.verify(mockOne, times(3)).simpleMethod(anyInt()); fail(); } catch (VerificationInOrderFailure e) {} }
Example #5
Source File: VerificationInOrderTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void shouldVerifyInOrderUsingMatcher() { mockOne.simpleMethod(1); mockOne.simpleMethod(2); mockTwo.differentMethod(); mockOne.simpleMethod(3); mockOne.simpleMethod(4); verify(mockOne, times(4)).simpleMethod(anyInt()); inOrder.verify(mockOne, times(2)).simpleMethod(anyInt()); inOrder.verify(mockTwo).differentMethod(); inOrder.verify(mockOne, times(2)).simpleMethod(anyInt()); try { inOrder.verify(mockOne, times(3)).simpleMethod(anyInt()); fail(); } catch (VerificationInOrderFailure e) {} }
Example #6
Source File: VerificationInOrderTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void shouldVerifyInOrderWhenTwoChunksAreEqual() { mockOne.simpleMethod(); mockOne.simpleMethod(); mockTwo.differentMethod(); mockOne.simpleMethod(); mockOne.simpleMethod(); inOrder.verify(mockOne, times(2)).simpleMethod(); inOrder.verify(mockTwo).differentMethod(); inOrder.verify(mockOne, times(2)).simpleMethod(); try { inOrder.verify(mockOne, atLeastOnce()).simpleMethod(); fail(); } catch (VerificationInOrderFailure e) {} }
Example #7
Source File: ExactNumberOfTimesVerificationTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void shouldAllowVerifyingInteractionNeverHappenedInOrder() throws Exception { mock.add("one"); mock.add("two"); InOrder inOrder = inOrder(mock); inOrder.verify(mock, never()).add("xxx"); inOrder.verify(mock).add("one"); inOrder.verify(mock, never()).add("one"); try { inOrder.verify(mock, never()).add("two"); fail(); } catch (VerificationInOrderFailure e) {} }
Example #8
Source File: VerificationInOrderTest.java From astor with GNU General Public License v2.0 | 6 votes |
@Test public void shouldVerifySingleMockInOrderAndNotInOrder() { mockOne = mock(IMethods.class); inOrder = inOrder(mockOne); mockOne.simpleMethod(1); mockOne.simpleMethod(2); verify(mockOne).simpleMethod(2); verify(mockOne).simpleMethod(1); inOrder.verify(mockOne).simpleMethod(2); try { inOrder.verify(mockOne).simpleMethod(1); fail(); } catch (VerificationInOrderFailure e) {} }
Example #9
Source File: TaxUpdaterTestNgTest.java From mockito-cookbook with Apache License 2.0 | 6 votes |
@Test public void should_fail_at_updating_tax_factor_and_transfer_tax_in_specified_order_due_to_greedy_at_least() throws Exception { // given Person person = new Person(); // when systemUnderTest.transferTaxFor(person); // then InOrder inOrder = Mockito.inOrder(taxService); inOrder.verify(taxService).updateTaxFactor(eq(person), anyDouble()); inOrder.verify(taxService, atLeastOnce()).transferTaxFor(person); try { inOrder.verify(taxService).updateTaxFactor(eq(person), anyDouble()); inOrder.verify(taxService).transferTaxFor(person); } catch (VerificationInOrderFailure verificationInOrderFailure) {} }
Example #10
Source File: BasicVerificationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailWhenLastMethodVerifiedFirst() { inOrder.verify(mockOne).simpleMethod(4); try { inOrder.verify(mockOne).simpleMethod(1); fail(); } catch (VerificationInOrderFailure e) { } }
Example #11
Source File: FindingRedundantInvocationsInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailToVerifyNoMoreInteractionsInOrder() throws Exception { //when mock.simpleMethod(); mock.simpleMethod(10); mock.otherMethod(); //then InOrder inOrder = inOrder(mock); inOrder.verify(mock).simpleMethod(10); try { inOrder.verifyNoMoreInteractions(); fail(); } catch(VerificationInOrderFailure e) {} }
Example #12
Source File: PointingStackTraceToActualInvocationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldPointToSecondMethod() { inOrder.verify(mock).simpleMethod(anyInt()); inOrder.verify(mockTwo).simpleMethod(anyInt()); try { inOrder.verify(mockTwo, times(3)).simpleMethod(999); fail(); } catch (VerificationInOrderFailure e) { assertContains("second(", e.getMessage()); } }
Example #13
Source File: PointingStackTraceToActualInvocationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldPointToFirstMethodBecauseOfTooManyActualInvocations() { try { inOrder.verify(mock, times(0)).simpleMethod(anyInt()); fail(); } catch (VerificationInOrderFailure e) { assertContains("first(", e.getMessage()); } }
Example #14
Source File: PointingStackTraceToActualInvocationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldPointToSecondMethodBecauseOfTooManyActualInvocations() { inOrder.verify(mock).simpleMethod(anyInt()); try { inOrder.verify(mockTwo, times(0)).simpleMethod(anyInt()); fail(); } catch (VerificationInOrderFailure e) { assertContains("second(", e.getMessage()); } }
Example #15
Source File: BasicVerificationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailWhenFirstMockCalledTwice() { inOrder.verify(mockOne).simpleMethod(1); try { inOrder.verify(mockOne).simpleMethod(1); fail(); } catch (VerificationInOrderFailure e) { } }
Example #16
Source File: NumberOfInvocationsInOrderCheckerTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldReportTooLittleInvocations() throws Exception { Invocation first = new InvocationBuilder().toInvocation(); Invocation second = new InvocationBuilder().toInvocation(); finderStub.validMatchingChunkToReturn.addAll(asList(first, second)); try { checker.check(invocations, wanted, 4, context); fail(); } catch (VerificationInOrderFailure e) { assertContains("Wanted 4 times", e.getMessage()); assertContains("But was 2 times", e.getMessage()); } }
Example #17
Source File: PointingStackTraceToActualInvocationChunkInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldPointToThirdChunkWhenTooLittleActualInvocations() { inOrder.verify(mock, times(2)).simpleMethod(anyInt()); inOrder.verify(mockTwo, times(2)).simpleMethod(anyInt()); inOrder.verify(mock, atLeastOnce()).simpleMethod(anyInt()); try { inOrder.verify(mockTwo, times(3)).simpleMethod(999); fail(); } catch (VerificationInOrderFailure e) { assertContains("thirdChunk(", e.getMessage()); } }
Example #18
Source File: BasicVerificationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailWhenMiddleMethodVerifiedFirst() { inOrder.verify(mockTwo, times(2)).simpleMethod(2); try { inOrder.verify(mockOne).simpleMethod(1); fail(); } catch (VerificationInOrderFailure e) { } }
Example #19
Source File: BasicVerificationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailWhenFirstMockCalledTwice() { inOrder.verify(mockOne).simpleMethod(1); try { inOrder.verify(mockOne).simpleMethod(1); fail(); } catch (VerificationInOrderFailure e) { } }
Example #20
Source File: SelectedMocksInOrderVerificationTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldThrowNoMoreInvocationsForMockTwo() { InOrder inOrder = inOrder(mockTwo); try { inOrder.verify(mockTwo, times(2)).simpleMethod(2); fail(); } catch (VerificationInOrderFailure e) {} }
Example #21
Source File: BasicVerificationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailOnLastMethodBecauseDifferentArgsWanted() { inOrder.verify(mockOne).simpleMethod(1); inOrder.verify(mockTwo, times(2)).simpleMethod(2); inOrder.verify(mockThree).simpleMethod(3); inOrder.verify(mockTwo).simpleMethod(2); try { inOrder.verify(mockOne).simpleMethod(-666); fail(); } catch (VerificationInOrderFailure e) { } }
Example #22
Source File: BasicVerificationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailOnSecondMethodBecauseDifferentMethodWanted() { inOrder.verify(mockOne, times(1)).simpleMethod(1); try { inOrder.verify(mockTwo, times(2)).oneArg(true); fail(); } catch (VerificationInOrderFailure e) { } }
Example #23
Source File: RelaxedVerificationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailOnLastTwoInvocationsInWrongOrder() { inOrder.verify(mockOne).simpleMethod(4); try { inOrder.verify(mockTwo, atLeastOnce()).simpleMethod(2); fail(); } catch (VerificationInOrderFailure e) {} }
Example #24
Source File: BasicVerificationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailOnLastMethodBecauseOneInvocationWantedAgain() { inOrder.verify(mockOne, atLeastOnce()).simpleMethod(1); inOrder.verify(mockTwo, times(2)).simpleMethod(2); inOrder.verify(mockThree, atLeastOnce()).simpleMethod(3); inOrder.verify(mockTwo, atLeastOnce()).simpleMethod(2); try { inOrder.verify(mockOne, times(2)).simpleMethod(4); fail(); } catch (VerificationInOrderFailure e) { } }
Example #25
Source File: BasicVerificationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailOnLastMethodBecauseOneInvocationWanted() { inOrder.verify(mockOne, atLeastOnce()).simpleMethod(1); inOrder.verify(mockTwo, times(2)).simpleMethod(2); inOrder.verify(mockThree, atLeastOnce()).simpleMethod(3); inOrder.verify(mockTwo, atLeastOnce()).simpleMethod(2); try { inOrder.verify(mockOne, times(0)).simpleMethod(4); fail(); } catch (VerificationInOrderFailure e) { } }
Example #26
Source File: BasicVerificationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailOnLastMethodBecauseOneInvocationWantedAgain() { inOrder.verify(mockOne, atLeastOnce()).simpleMethod(1); inOrder.verify(mockTwo, times(2)).simpleMethod(2); inOrder.verify(mockThree, atLeastOnce()).simpleMethod(3); inOrder.verify(mockTwo, atLeastOnce()).simpleMethod(2); try { inOrder.verify(mockOne, times(2)).simpleMethod(4); fail(); } catch (VerificationInOrderFailure e) { } }
Example #27
Source File: VerificationInOrderMixedWithOrdiraryVerificationTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailOnLastInvocationTooEarly() { inOrder.verify(mockThree).simpleMethod(4); verify(mockThree).simpleMethod(4); verify(mockTwo).simpleMethod(2); try { inOrder.verify(mockOne, atLeastOnce()).simpleMethod(1); fail(); } catch (VerificationInOrderFailure e) {} }
Example #28
Source File: RelaxedVerificationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldVerifyInteractionsFromAllChunksWhenAtLeastOnceMode() { inOrder.verify(mockTwo, atLeastOnce()).simpleMethod(2); verifyNoMoreInteractions(mockTwo); try { inOrder.verify(mockThree).simpleMethod(3); fail(); } catch (VerificationInOrderFailure e) {} }
Example #29
Source File: BasicVerificationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailWhenLastMockCalledTwice() { inOrder.verify(mockOne).simpleMethod(1); inOrder.verify(mockTwo, times(2)).simpleMethod(2); inOrder.verify(mockThree).simpleMethod(3); inOrder.verify(mockTwo).simpleMethod(2); inOrder.verify(mockOne).simpleMethod(4); try { inOrder.verify(mockOne).simpleMethod(4); fail(); } catch (VerificationInOrderFailure e) { } }
Example #30
Source File: BasicVerificationInOrderTest.java From astor with GNU General Public License v2.0 | 5 votes |
@Test public void shouldFailOnLastMethodBecauseDifferentMethodWanted() { inOrder.verify(mockOne).simpleMethod(1); inOrder.verify(mockTwo, times(2)).simpleMethod(2); inOrder.verify(mockThree).simpleMethod(3); inOrder.verify(mockTwo).simpleMethod(2); try { inOrder.verify(mockOne).oneArg(false); fail(); } catch (VerificationInOrderFailure e) { } }