use of org.mockito.invocation.Invocation 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);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class MissingInvocationInOrderCheckerTest method shouldReportWantedDiffersFromActual.
@Test
public void shouldReportWantedDiffersFromActual() throws Exception {
Invocation invocation1 = buildIntArgMethod().arg(1111).toInvocation();
Invocation invocation2 = buildIntArgMethod().arg(2222).toInvocation();
context.markVerified(invocation2);
invocations = asList(invocation1, invocation2);
wanted = buildIntArgMethod().arg(2222).toInvocationMatcher();
exception.expect(VerificationInOrderFailure.class);
exception.expectMessage("Verification in order failure");
exception.expectMessage("Wanted but not invoked:");
exception.expectMessage("mock.intArgumentMethod(2222);");
exception.expectMessage("Wanted anywhere AFTER following interaction:");
exception.expectMessage("mock.intArgumentMethod(2222);");
checkMissingInvocation(invocations, wanted, context);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class NumberOfInvocationsCheckerTest method shouldReportTooManyActual.
@Test
public void shouldReportTooManyActual() throws Exception {
Invocation first = buildSimpleMethod().toInvocation();
Invocation second = buildSimpleMethod().toInvocation();
invocations = asList(first, second);
wanted = buildSimpleMethod().toInvocationMatcher();
exception.expectMessage("Wanted 1 time");
exception.expectMessage("But was 2 times");
NumberOfInvocationsChecker.checkNumberOfInvocations(invocations, wanted, 1);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class NumberOfInvocationsCheckerTest method shouldReportWithFirstUndesiredInvocationStackTrace.
@Test
public void shouldReportWithFirstUndesiredInvocationStackTrace() throws Exception {
Invocation first = buildSimpleMethod().toInvocation();
Invocation second = buildSimpleMethod().toInvocation();
Invocation third = buildSimpleMethod().toInvocation();
invocations = asList(first, second, third);
wanted = buildSimpleMethod().toInvocationMatcher();
exception.expect(TooManyActualInvocations.class);
exception.expectMessage("" + third.getLocation());
NumberOfInvocationsChecker.checkNumberOfInvocations(invocations, wanted, 2);
}
use of org.mockito.invocation.Invocation in project mockito by mockito.
the class NumberOfInvocationsInOrderCheckerTest method shouldReportTooLittleInvocations.
@Test
public void shouldReportTooLittleInvocations() throws Exception {
Invocation first = buildSimpleMethod().toInvocation();
Invocation second = buildSimpleMethod().toInvocation();
wanted = buildSimpleMethod().toInvocationMatcher();
invocations = asList(first, second);
exception.expect(VerificationInOrderFailure.class);
exception.expectMessage("mock.simpleMethod()");
exception.expectMessage("Wanted 4 times");
exception.expectMessage("But was 2 times");
NumberOfInvocationsChecker.checkNumberOfInvocations(invocations, wanted, 4, context);
}
Aggregations