use of org.mockito.exceptions.misusing.InvalidUseOfMatchersException in project mockito by mockito.
the class MockHandlerImplTest method should_remove_verification_mode_even_when_invalid_matchers.
@Test
public void should_remove_verification_mode_even_when_invalid_matchers() throws Throwable {
// given
Invocation invocation = new InvocationBuilder().toInvocation();
@SuppressWarnings("rawtypes") MockHandlerImpl<?> handler = new MockHandlerImpl(new MockSettingsImpl());
mockingProgress().verificationStarted(VerificationModeFactory.atLeastOnce());
handler.matchersBinder = new MatchersBinder() {
public InvocationMatcher bindMatchers(ArgumentMatcherStorage argumentMatcherStorage, Invocation invocation) {
throw new InvalidUseOfMatchersException();
}
};
try {
// when
handler.handle(invocation);
// then
fail();
} catch (InvalidUseOfMatchersException ignored) {
}
assertNull(mockingProgress().pullVerificationMode());
}
use of org.mockito.exceptions.misusing.InvalidUseOfMatchersException in project mockito by mockito.
the class DetectingMisusedMatchersTest method should_report_argument_locations_when_argument_matchers_misused.
@Test
public void should_report_argument_locations_when_argument_matchers_misused() {
try {
Observer observer = mock(Observer.class);
misplaced_anyInt_argument_matcher();
misplaced_anyObject_argument_matcher();
misplaced_anyBoolean_argument_matcher();
observer.update(null, null);
validateMockitoUsage();
fail();
} catch (InvalidUseOfMatchersException e) {
assertThat(e).hasMessageContaining("DetectingMisusedMatchersTest.misplaced_anyInt_argument_matcher").hasMessageContaining("DetectingMisusedMatchersTest.misplaced_anyObject_argument_matcher").hasMessageContaining("DetectingMisusedMatchersTest.misplaced_anyBoolean_argument_matcher");
}
}
Aggregations