use of org.mockito.exceptions.base.MockitoException in project mockito by mockito.
the class InvocationContainerImplStubbingTest method should_validate_throwable_for_void_method.
@Test
public void should_validate_throwable_for_void_method() throws Throwable {
invocationContainerImpl.addAnswerForVoidMethod(new ThrowsException(new Exception()));
try {
invocationContainerImpl.setMethodForStubbing(new InvocationMatcher(simpleMethod));
fail();
} catch (MockitoException e) {
}
}
use of org.mockito.exceptions.base.MockitoException in project mockito by mockito.
the class ReturnsArgumentAtTest method should_fail_if_index_is_not_in_range_for_example_with_no_arg_invocation.
@Test
public void should_fail_if_index_is_not_in_range_for_example_with_no_arg_invocation() throws Throwable {
try {
new ReturnsArgumentAt(ReturnsArgumentAt.LAST_ARGUMENT).validateFor(new InvocationBuilder().simpleMethod().toInvocation());
fail();
} catch (MockitoException e) {
assertThat(e.getMessage()).containsIgnoringCase("invalid argument index").containsIgnoringCase("iMethods.simpleMethod").containsIgnoringCase("no arguments").containsIgnoringCase("last parameter wanted");
}
}
use of org.mockito.exceptions.base.MockitoException in project mockito by mockito.
the class MockitoRunnerBreaksWhenNoTestMethodsTest method ensure_the_test_runner_breaks.
@Test
public void ensure_the_test_runner_breaks() throws Exception {
JUnitCore runner = new JUnitCore();
// runner.addListener(new TextListener(System.out));
runner.addListener(new TextListener(DevNull.out));
Result result = runner.run(TestClassWithoutTestMethod.class);
assertEquals(1, result.getFailureCount());
assertTrue(result.getFailures().get(0).getException() instanceof MockitoException);
assertFalse(result.wasSuccessful());
}
use of org.mockito.exceptions.base.MockitoException in project mockito by mockito.
the class StackTraceFilteringTest method shouldFilterStackTraceWhenThrowingExceptionFromMockHandler.
@Test
public void shouldFilterStackTraceWhenThrowingExceptionFromMockHandler() {
try {
when(mock.oneArg(true)).thenThrow(new Exception());
fail();
} catch (MockitoException expected) {
Assertions.assertThat(expected).has(firstMethodInStackTrace("shouldFilterStackTraceWhenThrowingExceptionFromMockHandler"));
}
}
use of org.mockito.exceptions.base.MockitoException in project mockito by mockito.
the class StackTraceFilteringTest method shouldFilterStacktraceWhenInOrderVerifies.
@Test
public void shouldFilterStacktraceWhenInOrderVerifies() {
try {
InOrder inOrder = inOrder(mock);
inOrder.verify(null);
fail();
} catch (MockitoException expected) {
Assertions.assertThat(expected).has(firstMethodInStackTrace("shouldFilterStacktraceWhenInOrderVerifies"));
}
}
Aggregations