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 } } }
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 } } }
public void run() { ExecutorService service = Executors.newSingleThreadExecutor(); Callable<Object> callable = new Callable<Object>() { public Object call() throws Exception { runTestMethod(); return null; } }; Future<Object> result = service.submit(callable); service.shutdown(); try { boolean terminated = service.awaitTermination(timeout, TimeUnit.MILLISECONDS); if (!terminated) { service.shutdownNow(); } result.get(0, TimeUnit.MILLISECONDS); // throws the exception if one occurred during the invocation } catch (TimeoutException e) { addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout))); } catch (Exception e) { addFailure(e); } } });
public void run() { ExecutorService service = Executors.newSingleThreadExecutor(); Callable<Object> callable = new Callable<Object>() { public Object call() throws Exception { runTestMethod(); return null; } }; Future<Object> result = service.submit(callable); service.shutdown(); try { boolean terminated = service.awaitTermination(timeout, TimeUnit.MILLISECONDS); if (!terminated) { service.shutdownNow(); } result.get(0, TimeUnit.MILLISECONDS); // throws the exception if one occurred during the invocation } catch (TimeoutException e) { addFailure(new TestTimedOutException(timeout, TimeUnit.MILLISECONDS)); } catch (Exception e) { addFailure(e); } } });
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 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); } }
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(); } }
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(); } }
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 } } }
public void run() { ExecutorService service = Executors.newSingleThreadExecutor(); Callable<Object> callable = new Callable<Object>() { public Object call() throws Exception { runTestMethod(); return null; } }; Future<Object> result = service.submit(callable); service.shutdown(); try { boolean terminated = service.awaitTermination(timeout, TimeUnit.MILLISECONDS); if (!terminated) { service.shutdownNow(); } result.get(0, TimeUnit.MILLISECONDS); // throws the exception if one occurred during the invocation } catch (TimeoutException e) { addFailure(new Exception(String.format("test timed out after %d milliseconds", timeout))); } catch (Exception e) { addFailure(e); } } });
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); } }
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(); } }
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 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 } } }
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 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 } } }
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(); } }
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(); } }
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(); } }
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(); } }