use of org.mockito.exceptions.verification.NoInteractionsWanted in project mockito by mockito.
the class NoMoreInteractionsTest method noMoreInteractionsExceptionMessageShouldDescribeMock.
@Test
public void noMoreInteractionsExceptionMessageShouldDescribeMock() {
// given
NoMoreInteractions n = new NoMoreInteractions();
IMethods mock = mock(IMethods.class, "a mock");
InvocationMatcher i = new InvocationBuilder().mock(mock).toInvocationMatcher();
InvocationContainerImpl invocations = new InvocationContainerImpl(new MockSettingsImpl());
invocations.setInvocationForPotentialStubbing(i);
try {
// when
n.verify(new VerificationDataImpl(invocations, null));
// then
fail();
} catch (NoInteractionsWanted e) {
Assertions.assertThat(e.toString()).contains(mock.toString());
}
}
use of org.mockito.exceptions.verification.NoInteractionsWanted in project mockito by mockito.
the class StaticMockingExperimentTest method verify_no_more_interactions.
@Test
public void verify_no_more_interactions() throws Throwable {
// works for now because there are not interactions
verifyNoMoreInteractions(mock);
// register staticMethod call on mock
Invocation invocation = Mockito.framework().getInvocationFactory().createInvocation(mock, withSettings().build(Foo.class), staticMethod, realMethod, "foo");
handler.handle(invocation);
// fails now because we have one static invocation recorded
try {
verifyNoMoreInteractions(mock);
fail();
} catch (NoInteractionsWanted e) {
}
}
Aggregations