/** {@inheritDoc} */ @Override protected Statement methodInvoker(final FrameworkMethod method, final Object test) { return new InvokeMethod(method, test) { @Override // CHECKSTYLE:CHECK-OFF IllegalThrow // inherited JUnit throw style public void evaluate() throws Throwable { // CHECKSTYLE:CHECK-ON IllegalThrow try { super.evaluate(); // CHECKSTYLE:CHECK-OFF IllegalCatch // catching in order to act upon but then throwing the exception again } catch (final Throwable throwable) { // CHECKSTYLE:CHECK-ON IllegalCatch testRunRecording.methodInvokeFailure(throwable); throw throwable; } } }; }
/** * {@inheritDoc} */ @Override protected void runChild(final FrameworkMethod method, final RunNotifier notifier) { final Description description = describeChild(method); if (isIgnored(method)) { notifier.fireTestIgnored(description); } else { final InvokeMethod statement = (InvokeMethod) methodBlock(method); final Object test = ReflexUtils.getFieldValue(statement, "target"); final ConditionChecker<?> checker = ConditionCheckerEngine.detectFailedChecker(test, method); if (checker != null) { notifier.fireTestIgnored(description); } else { runLeaf(statement, description, notifier); } } }
private void runSingleTest(FrameworkMethod method, RunNotifier notifier) throws IllegalAccessException, InvocationTargetException, InstantiationException { Object test = getTestClass().getOnlyConstructor().newInstance(); Statement statement = new InvokeMethod(method, test); Description description = describeChild(method); notifier.fireTestStarted(description); try { statement.evaluate(); if (method.getName().endsWith("MustFail")) { notifier.fireTestFailure(new Failure(description, new RuntimeException("Test didn't fail."))); } } catch (Throwable e) { if (!method.getName().endsWith("MustFail")) { notifier.fireTestFailure(new Failure(description, e)); } } finally { notifier.fireTestFinished(description); } }
public static void runRule(TestRule rule, Object target, String methodName) { Class<?> clazz = target.getClass(); Method method = TestUtils.getMethod(clazz, methodName); Description description = Description.createTestDescription(clazz, method.getName(), method.getDeclaredAnnotations()); try { InvokeMethod invokeMethod = new InvokeMethod(new FrameworkMethod(method), target); rule.apply(invokeMethod, description).evaluate(); } catch (Throwable throwable) { logger.warning(Arrays.toString(throwable.getStackTrace())); } }
private Statement methodBlock(FrameworkMethod method) { Object testObject; try { testObject = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return getTestClass().getOnlyConstructor().newInstance(new Object[0]); } }.run(); } catch (Throwable throwable) { return new Fail(throwable); } return new InvokeMethod(method, testObject); }
/** * Returns a {@link org.junit.runners.model.Statement} that invokes {@code method} on {@code test} */ protected Statement methodInvoker(FrameworkMethod method, Object test) { return new InvokeMethod(method, test); }
/** * Returns a {@link Statement} that invokes {@code method} on {@code test} */ protected Statement methodInvoker(FrameworkMethod method, Object test) { return new InvokeMethod(method, test); }
/** * Returns a {@link Statement} that invokes {@code method} on {@code test} */ @Override protected Statement methodInvoker(FrameworkMethod method, Object test) { return new InvokeMethod(convert(method), test); }
protected Statement buildStatement(final TestClass testClass, final FrameworkMethod method, final Object target, final Description description, final RunNotifier notifier) { return new InvokeMethod(method, target); }
@Override protected Statement methodInvoker(FrameworkMethod method, Object test) { ComplianceSuiteTest eTest = (ComplianceSuiteTest) test; eTest.setExecutor(executor); return new InvokeMethod(method, test); }