use of org.mockitousage.IMethods in project mockito by mockito.
the class VerificationCollectorImplTest method should_collect_verification_failures.
@Test(expected = MockitoAssertionError.class)
public void should_collect_verification_failures() {
VerificationCollector collector = MockitoJUnit.collector().assertLazily();
IMethods methods = mock(IMethods.class);
verify(methods).simpleMethod();
collector.collectAndReport();
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class VerificationCollectorImplTest method should_continue_collecting_after_failing_verification.
@Test
public void should_continue_collecting_after_failing_verification() {
VerificationCollector collector = MockitoJUnit.collector().assertLazily();
IMethods methods = mock(IMethods.class);
methods.simpleMethod();
verify(methods).byteReturningMethod();
verify(methods).simpleMethod();
this.assertAtLeastOneFailure(collector);
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class VerificationCollectorImplTest method should_only_collect_failures_ignore_succesful_verifications.
@Test
public void should_only_collect_failures_ignore_succesful_verifications() {
VerificationCollector collector = MockitoJUnit.collector().assertLazily();
IMethods methods = mock(IMethods.class);
verify(methods, never()).simpleMethod();
verify(methods).byteReturningMethod();
this.assertAtLeastOneFailure(collector);
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksSerializationForAnnotationTest method should_serialize_with_stubbing_callback.
@Test
public void should_serialize_with_stubbing_callback() throws Exception {
// given
CustomAnswersMustImplementSerializableForSerializationToWork answer = new CustomAnswersMustImplementSerializableForSerializationToWork();
answer.string = "return value";
when(imethodsMock.objectArgMethod(anyString())).thenAnswer(answer);
// when
ByteArrayOutputStream serialized = serializeMock(imethodsMock);
// then
IMethods readObject = deserializeMock(serialized, IMethods.class);
assertEquals(answer.string, readObject.objectArgMethod(""));
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksSerializationForAnnotationTest method should_remember_interactions_for_serialized_mock.
@Test
public void should_remember_interactions_for_serialized_mock() throws Exception {
List<?> value = Collections.emptyList();
when(imethodsMock.objectArgMethod(anyString())).thenReturn(value);
imethodsMock.objectArgMethod("happened");
// when
ByteArrayOutputStream serialized = serializeMock(imethodsMock);
// then
IMethods readObject = deserializeMock(serialized, IMethods.class);
verify(readObject, never()).objectArgMethod("never happened");
}
Aggregations