use of org.mockitousage.IMethods in project mockito by mockito.
the class BasicStubbingTest method should_allow_stubbing_to_string.
@Test
public void should_allow_stubbing_to_string() throws Exception {
IMethods mockTwo = mock(IMethods.class);
when(mockTwo.toString()).thenReturn("test");
assertThat(mock.toString()).contains("Mock for IMethods");
assertThat(mockTwo.toString()).isEqualTo("test");
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class BasicStubbingTest method should_to_string_mock_name.
@Test
public void should_to_string_mock_name() {
IMethods mock = mock(IMethods.class, "mockie");
IMethods mockTwo = mock(IMethods.class);
assertThat(mockTwo.toString()).contains("Mock for IMethods");
assertEquals("mockie", "" + mock);
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class StubbingWithDelegateTest method exception_should_be_propagated_from_delegate.
@Test
public void exception_should_be_propagated_from_delegate() throws Exception {
final RuntimeException failure = new RuntimeException("angry-method");
IMethods methods = mock(IMethods.class, delegatesTo(new MethodsImpl() {
@Override
public String simpleMethod() {
throw failure;
}
}));
try {
// delegate throws an exception
methods.simpleMethod();
fail();
} catch (RuntimeException e) {
assertThat(e).isEqualTo(failure);
}
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class BasicVerificationTest method shouldDetectWhenOverloadedMethodCalled.
@Test
public void shouldDetectWhenOverloadedMethodCalled() throws Exception {
IMethods mockThree = mock(IMethods.class);
mockThree.varargs((Object[]) new Object[] {});
try {
verify(mockThree).varargs((String[]) new String[] {});
fail();
} catch (WantedButNotInvoked e) {
}
}
Aggregations