protected void runTestMethod() { try { testMethod.invoke(test); if (testMethod.expectsException()) { addFailure(new AssertionError("Expected exception: " + testMethod.getExpectedException().getName())); } } catch (InvocationTargetException e) { Throwable actual = e.getTargetException(); if (actual instanceof AssumptionViolatedException) { return; } else if (!testMethod.expectsException()) { addFailure(actual); } else if (testMethod.isUnexpected(actual)) { String message = "Unexpected exception, expected<" + testMethod.getExpectedException().getName() + "> but was<" + actual.getClass().getName() + ">"; addFailure(new Exception(message, actual)); } } catch (Throwable e) { addFailure(e); } }
protected TestMethod wrapMethod(Method method) { return new TestMethod(method, testClass); }
private void runAfters() { List<Method> afters = testMethod.getAfters(); for (Method after : afters) { try { after.invoke(test); } catch (InvocationTargetException e) { addFailure(e.getTargetException()); } catch (Throwable e) { addFailure(e); // Untested, but seems impossible } } }
public void run() { if (testMethod.isIgnored()) { notifier.fireTestIgnored(description); return; } notifier.fireTestStarted(description); try { long timeout = testMethod.getTimeout(); if (timeout > 0) { runWithTimeout(timeout); } else { runTest(); } } finally { notifier.fireTestFinished(description); } }
boolean expectsException() { return getExpectedException() != null; }
private void runBefores() throws FailedBefore { try { try { List<Method> befores = testMethod.getBefores(); for (Method before : befores) { before.invoke(test); } } catch (InvocationTargetException e) { throw e.getTargetException(); } } catch (AssumptionViolatedException e) { throw new FailedBefore(); } catch (Throwable e) { addFailure(e); throw new FailedBefore(); } }
@Override public void invoke(final Object testFixture) throws IllegalAccessException, InvocationTargetException { super.invoke(testFixture); if (mockeryField != null) { mockeryOf(testFixture).assertIsSatisfied(); } } };
public void run() { if (fTestMethod.isIgnored()) { fNotifier.fireTestIgnored(fDescription); return; } fNotifier.fireTestStarted(fDescription); try { long timeout = fTestMethod.getTimeout(); if (timeout > 0) { runWithTimeout(timeout); } else { runTest(); } } finally { fNotifier.fireTestFinished(fDescription); } }
boolean expectsException() { return getExpectedException() != null; }
private void runBefores() throws FailedBefore { try { try { List<Method> befores = fTestMethod.getBefores(); for (Method before : befores) { before.invoke(fTest); } } catch (InvocationTargetException e) { throw e.getTargetException(); } } catch (AssumptionViolatedException e) { throw new FailedBefore(); } catch (Throwable e) { addFailure(e); throw new FailedBefore(); } }
@Override public void invoke(final Object testFixture) throws IllegalAccessException, InvocationTargetException { super.invoke(testFixture); if (mockeryField != null) { mockeryOf(testFixture).assertIsSatisfied(); } } };
protected void runTestMethod() { try { fTestMethod.invoke(fTest); if (fTestMethod.expectsException()) { addFailure(new AssertionError("Expected exception: " + fTestMethod.getExpectedException().getName())); } } catch (InvocationTargetException e) { Throwable actual = e.getTargetException(); if (actual instanceof AssumptionViolatedException) { return; } else if (!fTestMethod.expectsException()) { addFailure(actual); } else if (fTestMethod.isUnexpected(actual)) { String message = "Unexpected exception, expected<" + fTestMethod.getExpectedException().getName() + "> but was<" + actual.getClass().getName() + ">"; addFailure(new Exception(message, actual)); } } catch (Throwable e) { addFailure(e); } }
public void run() { if (fTestMethod.isIgnored()) { fNotifier.fireTestIgnored(fDescription); return; } fNotifier.fireTestStarted(fDescription); try { long timeout = fTestMethod.getTimeout(); if (timeout > 0) { runWithTimeout(timeout); } else { runTest(); } } finally { fNotifier.fireTestFinished(fDescription); } }
protected TestMethod wrapMethod(Method method) { return new TestMethod(method, fTestClass); }
boolean isUnexpected(Throwable exception) { return !getExpectedException().isAssignableFrom(exception.getClass()); }
private void runAfters() { List<Method> afters = fTestMethod.getAfters(); for (Method after : afters) { try { after.invoke(fTest); } catch (InvocationTargetException e) { addFailure(e.getTargetException()); } catch (Throwable e) { addFailure(e); // Untested, but seems impossible } } }
private void runBefores() throws FailedBefore { try { try { List<Method> befores = fTestMethod.getBefores(); for (Method before : befores) { before.invoke(fTest); } } catch (InvocationTargetException e) { throw e.getTargetException(); } } catch (AssumptionViolatedException e) { throw new FailedBefore(); } catch (Throwable e) { addFailure(e); throw new FailedBefore(); } }
@Override public void invoke(final Object testFixture) throws IllegalAccessException, InvocationTargetException { super.invoke(testFixture); if (mockeryField != null) { mockeryOf(testFixture).assertIsSatisfied(); } } };
protected void runTestMethod() { try { fTestMethod.invoke(fTest); if (fTestMethod.expectsException()) { addFailure(new AssertionError("Expected exception: " + fTestMethod.getExpectedException().getName())); } } catch (InvocationTargetException e) { Throwable actual = e.getTargetException(); if (actual instanceof AssumptionViolatedException) { return; } else if (!fTestMethod.expectsException()) { addFailure(actual); } else if (fTestMethod.isUnexpected(actual)) { String message = "Unexpected exception, expected<" + fTestMethod.getExpectedException().getName() + "> but was<" + actual.getClass().getName() + ">"; addFailure(new Exception(message, actual)); } } catch (Throwable e) { addFailure(e); } }
public void run() { if (fTestMethod.isIgnored()) { fNotifier.fireTestIgnored(fDescription); return; } fNotifier.fireTestStarted(fDescription); try { long timeout = fTestMethod.getTimeout(); if (timeout > 0) { runWithTimeout(timeout); } else { runTest(); } } finally { fNotifier.fireTestFinished(fDescription); } }