use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksSerializationTest method should_be_serialize_and_have_extra_interfaces.
@Test
public void should_be_serialize_and_have_extra_interfaces() throws Exception {
//when
IMethods mock = mock(IMethods.class, withSettings().serializable().extraInterfaces(List.class));
IMethods mockTwo = mock(IMethods.class, withSettings().extraInterfaces(List.class).serializable());
//then
Assertions.assertThat((Object) serializeAndBack((List) mock)).isInstanceOf(List.class).isInstanceOf(IMethods.class);
Assertions.assertThat((Object) serializeAndBack((List) mockTwo)).isInstanceOf(List.class).isInstanceOf(IMethods.class);
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksSerializationTest method should_allow_mock_to_be_serializable.
@Test
public void should_allow_mock_to_be_serializable() throws Exception {
// given
IMethods mock = mock(IMethods.class, withSettings().serializable());
// when-serialize then-deserialize
serializeAndBack(mock);
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class ResetTest method shouldNotAffectMockName.
@Test
public void shouldNotAffectMockName() {
IMethods mock = mock(IMethods.class, "mockie");
IMethods mockTwo = mock(IMethods.class);
reset(mock);
assertThat(mockTwo.toString()).contains("Mock for IMethods");
assertEquals("mockie", "" + mock);
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class ArgumentCaptorDontCapturePreviouslyVerifiedTest method previous_verified_invocation_should_still_capture_args.
@Test
public void previous_verified_invocation_should_still_capture_args() {
IMethods mock = mock(IMethods.class);
mock.oneArg("first");
ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
verify(mock, times(1)).oneArg(argument.capture());
assertThat(argument.getAllValues()).hasSize(1);
// additional interactions
mock.oneArg("second");
argument = ArgumentCaptor.forClass(String.class);
verify(mock, times(2)).oneArg(argument.capture());
assertThat(argument.getAllValues()).hasSize(2);
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class VerificationCollectorImplTest method should_collect_multiple_verification_failures.
@Test
public void should_collect_multiple_verification_failures() {
VerificationCollector collector = MockitoJUnit.collector().assertLazily();
IMethods methods = mock(IMethods.class);
verify(methods).simpleMethod();
verify(methods).byteReturningMethod();
try {
collector.collectAndReport();
fail();
} catch (MockitoAssertionError error) {
assertThat(error).hasMessageContaining("1. Wanted but not invoked:");
assertThat(error).hasMessageContaining("2. Wanted but not invoked:");
}
}
Aggregations