use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksCreationTest method shouldCombineMockNameAndSmartNulls.
@Test
public void shouldCombineMockNameAndSmartNulls() {
//given
IMethods mock = mock(IMethods.class, withSettings().defaultAnswer(RETURNS_SMART_NULLS).name("great mockie"));
//when
IMethods smartNull = mock.iMethodsReturningMethod();
String name = mock.toString();
//then
assertThat(name).contains("great mockie");
//and
try {
smartNull.simpleMethod();
fail();
} catch (SmartNullPointerException e) {
}
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksCreationTest method shouldCombineMockNameAndExtraInterfaces.
@Test
public void shouldCombineMockNameAndExtraInterfaces() {
//given
IMethods mock = mock(IMethods.class, withSettings().extraInterfaces(List.class).name("great mockie"));
//when
String name = mock.toString();
//then
assertThat(name).contains("great mockie");
//and
assertTrue(mock instanceof List);
}
use of org.mockitousage.IMethods 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());
}
}
use of org.mockitousage.IMethods 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.mockitousage.IMethods in project mockito by mockito.
the class StubbingMocksThatAreConfiguredToReturnMocksTest method shouldAllowStubbingMocksConfiguredWithRETURNS_MOCKSWithDoApi.
@Test
public void shouldAllowStubbingMocksConfiguredWithRETURNS_MOCKSWithDoApi() {
IMethods mock = mock(IMethods.class, RETURNS_MOCKS);
doReturn(null).when(mock).objectReturningMethodNoArgs();
}
Aggregations