protected Statement methodBlock(FrameworkMethod method) { Object test; try { test = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable e) { return new Fail(e); } Statement statement = methodInvoker(method, test); statement = possiblyExpectingExceptions(method, test, statement); statement = withPotentialTimeout(method, test, statement); statement = withBefores(method, test, statement); statement = withAfters(method, test, statement); statement = withRules(method, test, statement); return statement; }
/** * Augment the default JUnit behavior * {@linkplain #withPotentialRepeat with potential repeats} of the entire * execution chain. * <p>Furthermore, support for timeouts has been moved down the execution * chain in order to include execution of {@link org.junit.Before @Before} * and {@link org.junit.After @After} methods within the timed execution. * Note that this differs from the default JUnit behavior of executing * {@code @Before} and {@code @After} methods in the main thread while * executing the actual test method in a separate thread. Thus, the net * effect is that {@code @Before} and {@code @After} methods will be * executed in the same thread as the test method. As a consequence, * JUnit-specified timeouts will work fine in combination with Spring * transactions. However, JUnit-specific timeouts still differ from * Spring-specific timeouts in that the former execute in a separate * thread while the latter simply execute in the main thread (like regular * tests). * @see #possiblyExpectingExceptions(FrameworkMethod, Object, Statement) * @see #withBefores(FrameworkMethod, Object, Statement) * @see #withAfters(FrameworkMethod, Object, Statement) * @see #withRulesReflectively(FrameworkMethod, Object, Statement) * @see #withPotentialRepeat(FrameworkMethod, Object, Statement) * @see #withPotentialTimeout(FrameworkMethod, Object, Statement) */ @Override protected Statement methodBlock(FrameworkMethod frameworkMethod) { Object testInstance; try { testInstance = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable ex) { return new Fail(ex); } Statement statement = methodInvoker(frameworkMethod, testInstance); statement = possiblyExpectingExceptions(frameworkMethod, testInstance, statement); statement = withBefores(frameworkMethod, testInstance, statement); statement = withAfters(frameworkMethod, testInstance, statement); statement = withRulesReflectively(frameworkMethod, testInstance, statement); statement = withPotentialRepeat(frameworkMethod, testInstance, statement); statement = withPotentialTimeout(frameworkMethod, testInstance, statement); return statement; }
/** * Extends a given {@link Statement} for a {@link TestClass} with the evaluation of * {@link TestRule}, {@link ClassRule}, {@link Before} and {@link After}. * <p> * Therefore the test class will be instantiated and parameters will be injected with the same * mechanism as in {@link Parameterized}. * * Implementation has been extracted from BlockJUnit4ClassRunner#methodBlock(FrameworkMethod). * * @param baseStatementWithChildren - A {@link Statement} that includes execution of the test's * children * @param testClass - The {@link TestClass} of the test. * @param description - The {@link Description} will be passed to the {@link Rule}s and * {@link ClassRule}s. * @param singleParameter - The parameters will be injected in attributes annotated with * {@link Parameterized.Parameter} or passed to the constructor otherwise. * * @see BlockJUnit4ClassRunnerWithParameters#createTest() * @see BlockJUnit4ClassRunner#methodBlock(FrameworkMethod) */ public static Statement buildStatementWithTestRules(Statement baseStatementWithChildren, final TestClass testClass, Description description, final Object[] singleParameter) { final Object test; try { test = new ReflectiveCallable() { protected Object runReflectiveCall() throws Throwable { return createInstanceOfParameterizedTest(testClass, singleParameter); } }.run(); } catch (Throwable e) { return new Fail(e); } List<TestRule> testRules = BlockJUnit4ClassRunnerUtil.getTestRules(test, testClass); Statement statement = BlockJUnit4ClassRunnerUtil.withTestRules(testRules, description, baseStatementWithChildren); statement = ParentRunnerUtil.withBeforeClasses(statement, testClass); statement = ParentRunnerUtil.withAfterClasses(statement, testClass); statement = ParentRunnerUtil.withClassRules(statement, testClass, description); return statement; }
/** * Augment the default JUnit behavior * <p>Furthermore, support for timeouts has been moved down the execution * chain in order to include execution of {@link org.junit.Before @Before} * and {@link org.junit.After @After} methods within the timed execution. * Note that this differs from the default JUnit behavior of executing * {@code @Before} and {@code @After} methods in the main thread while * executing the actual test method in a separate thread. Thus, the net * effect is that {@code @Before} and {@code @After} methods will be * executed in the same thread as the test method. As a consequence, * JUnit-specified timeouts will work fine in combination with Spring * transactions. However, JUnit-specific timeouts still differ from * Spring-specific timeouts in that the former execute in a separate * thread while the latter simply execute in the main thread (like regular * tests). * * @see #methodInvoker(FrameworkMethod, Object) * @see #possiblyExpectingExceptions(FrameworkMethod, Object, Statement) * @see #withBefores(FrameworkMethod, Object, Statement) * @see #withAfters(FrameworkMethod, Object, Statement) * @see #withPotentialTimeout(FrameworkMethod, Object, Statement) */ @Override protected Statement methodBlock(FrameworkMethod frameworkMethod) { Object testInstance; try { testInstance = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable ex) { return new Fail(ex); } Environment.inject(testInstance); Statement statement = methodInvoker(frameworkMethod, testInstance); statement = possiblyExpectingExceptions(frameworkMethod, testInstance, statement); statement = withBefores(frameworkMethod, testInstance, statement); statement = withAfters(frameworkMethod, testInstance, statement); statement = withPotentialTimeout(frameworkMethod, testInstance, statement); return statement; }
@Override protected Statement methodBlock(FrameworkMethod frameworkMethod) { testContext = new TestContextImpl(new HashMap<>(classAttributes), null); Object testInstance; try { testInstance = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable ex) { return new Fail(ex); } Environment.inject(testInstance); Statement statement = methodInvoker(frameworkMethod, testInstance); statement = possiblyExpectingExceptions(frameworkMethod, testInstance, statement); statement = withBefores(frameworkMethod, testInstance, statement); statement = withAfters(frameworkMethod, testInstance, statement); statement = withPotentialTimeout(frameworkMethod, testInstance, statement); testContext = null; return statement; }
public ParentRunner<?> makeLink(Class<? extends ParentRunner<?>> runnerClass, final Class<?> testClass, final CompositeRunner compositeRunner, final ParentRunner<?> nextRunner, boolean isTestStructureProvider) throws InitializationError { ClassPool pool = ClassPool.getDefault(); String newClassName = runnerClass.getName() + (isTestStructureProvider ? "TestStructureProvider" : "ChainLink"); final Class<?> newRunnerCtClass = makeLinkClass(pool, newClassName, runnerClass, isTestStructureProvider); try { return (ParentRunner<?>) new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return newRunnerCtClass.getConstructor(Class.class, CompositeRunner.class, ParentRunner.class) .newInstance(testClass, compositeRunner, nextRunner); } }.run(); } catch (InitializationError e) { throw e; } catch (Throwable throwable) { throw new RuntimeException(throwable); } }
protected Statement methodBlock( FuzzUnitTestMethod testMethod ) { Object test; try { test = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch( Throwable e ) { return new Fail( e ); } Statement statement = methodInvoker( testMethod, test ); statement = withRules( testMethod, test, statement ); return statement; }
/** * method taken as is from BlockJUnit4ClassRunner 4.7 in order to preserve * its functionality over following versions */ @Override protected Statement methodBlock(FrameworkMethod method) { Object test; try { test = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable e) { return new Fail(e); } Statement statement = methodInvoker(method, test); statement = possiblyExpectingExceptions(method, test, statement); statement = withPotentialTimeout(method, test, statement); statement = withRules(method, test, statement); statement = withBefores(method, test, statement); statement = withAfters(method, test, statement); return statement; }
@Override protected Statement methodBlock(final FrameworkMethod method) { final Object test; try { test = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (final Throwable e) { return new Fail(e); } Statement statement = new MetaTest.$(method, test); statement = withBefores(method, test, statement); statement = withAfters(method, test, statement); return statement; }
@Override protected Statement methodBlock(final FrameworkMethod method) { final Object test; try { test = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (final Throwable e) { return new Fail(e); } Statement statement = new InvokeMethod(method, test); statement = withBefores(method, test, statement); statement = withAfters(method, test, statement); return statement; }
/** * had to override this whole method to get enough overall control to wrap * all method invocations... javadoc says that this can be overridden */ @Override protected Statement methodBlock(FrameworkMethod method) { Object test; try { test= new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable e) { return new Fail(e); } Statement statement= methodInvoker(method, test); statement= possiblyExpectingExceptions(method, test, statement); statement= withPotentialTimeout(method, test, statement); statement= withBefores(method, test, statement); statement= withAfters(method, test, statement); statement= withRules(method, test, statement); return statement; }
@Override public Object invokeExplosively(Object target, Object... params) throws Throwable { // TODO: ok to ignore parameters here? i guess it depends on the Runner if they are used. return new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return nextRunnerRunChild.invoke(nextRunner, wrapped, runNotifier); } }.run(); }
public static Statement invokeClassBlock(final ParentRunner<?> nextRunner, final RunNotifier notifier) { try { return (Statement)new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { Method classBlockMethod = ParentRunner.class.getDeclaredMethod("classBlock", RunNotifier.class); classBlockMethod.setAccessible(true); return classBlockMethod.invoke(nextRunner, notifier); } }.run(); } catch (Throwable throwable) { throw new RuntimeException(throwable); } }
public static List invokeGetChildren(final ParentRunner<?> runner) { try { return (List)new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { Method getChildrenMethod = ParentRunner.class.getDeclaredMethod("getChildren"); getChildrenMethod.setAccessible(true); return getChildrenMethod.invoke(runner); } }.run(); } catch (Throwable throwable) { throw new RuntimeException(throwable); } }
public static Description invokeDescribeChild(final ParentRunner<?> runner, final Object child) { try { return (Description) new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { Method describeChildMethod = ParentRunner.class.getDeclaredMethod("describeChild", Object.class); describeChildMethod.setAccessible(true); return describeChildMethod.invoke(runner, child); } }.run(); } catch (Throwable throwable) { throw new RuntimeException(throwable); } }
@Override public void evaluate() throws Throwable { final Method runChildrenMethod = ParentRunner.class.getDeclaredMethod("runChildren", RunNotifier.class); runChildrenMethod.setAccessible(true); new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return runChildrenMethod.invoke(runner, notifier); } }.run(); }
public static Object invoke(final Method method, final Object... args) { try { return new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return method.invoke(currentTestInstance.peek(), args); } }.run(); } catch (Throwable throwable) { throw new RuntimeException(throwable); } }
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 the result of invoking this method on {@code target} with * parameters {@code params}. {@link InvocationTargetException}s thrown are * unwrapped, and their causes rethrown. */ public Object invokeExplosively(final Object target, final Object... params) throws Throwable { return new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return fMethod.invoke(target, params); } }.run(); }
@Override public Object invokeExplosively(final Object target, Object... params) throws Throwable { checkNotNull(target, "target"); ReflectiveCallable callable = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return getMethod().invoke(target, methodArgs); } }; return callable.run(); }
/** * Augments the default JUnit behavior * {@link #withPotentialRepeat(FrameworkMethod, Object, Statement) with * potential repeats} of the entire execution chain. * <p>Furthermore, support for timeouts has been moved down the execution chain * in order to include execution of {@link org.junit.Before @Before} * and {@link org.junit.After @After} methods within the timed * execution. Note that this differs from the default JUnit behavior of * executing {@code @Before} and {@code @After} methods * in the main thread while executing the actual test method in a separate * thread. Thus, the end effect is that {@code @Before} and * {@code @After} methods will be executed in the same thread as * the test method. As a consequence, JUnit-specified timeouts will work * fine in combination with Spring transactions. Note that JUnit-specific * timeouts still differ from Spring-specific timeouts in that the former * execute in a separate thread while the latter simply execute in the main * thread (like regular tests). * @see #possiblyExpectingExceptions(FrameworkMethod, Object, Statement) * @see #withBefores(FrameworkMethod, Object, Statement) * @see #withAfters(FrameworkMethod, Object, Statement) * @see #withPotentialTimeout(FrameworkMethod, Object, Statement) * @see #withPotentialRepeat(FrameworkMethod, Object, Statement) */ @Override protected Statement methodBlock(FrameworkMethod frameworkMethod) { Object testInstance; try { testInstance = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable ex) { return new Fail(ex); } Statement statement = methodInvoker(frameworkMethod, testInstance); statement = possiblyExpectingExceptions(frameworkMethod, testInstance, statement); statement = withBefores(frameworkMethod, testInstance, statement); statement = withAfters(frameworkMethod, testInstance, statement); statement = withRulesReflectively(frameworkMethod, testInstance, statement); statement = withPotentialRepeat(frameworkMethod, testInstance, statement); statement = withPotentialTimeout(frameworkMethod, testInstance, statement); return statement; }
protected Object createTestObject() throws Throwable { return new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); }
@SuppressWarnings("deprecation") @Override protected Statement methodBlock(final FrameworkMethod method) { Object test; try { test = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable e) { return new Fail(e); } Statement statement = methodInvoker(method, test); statement = withTransaction(method, test, statement); statement = possiblyExpectingExceptions(method, test, statement); statement = withPotentialTimeout(method, test, statement); statement = withFieldsBinding(method, test, statement); statement = withContainer(method, test, statement); statement = withBefores(method, test, statement); statement = withAfters(method, test, statement); statement = withContext(method, test, statement); statement = withRootContainer(method, test, statement); statement = withClassLoader(statement); statement = withRules(method, test, statement); return statement; }
/** * Gets the PerformanceJUnitStatement for the test execution of the given method. * * @param currentMethod * Method that should be tested * @return PerformanceJUnitStatement for testing the method * @throws NoSuchMethodException * Thrown if the method does not exist * @throws SecurityException * Thrown if the method is not accessible * @throws IllegalAccessException * Thrown if the method is not accessible * @throws IllegalArgumentException * Thrown if the method has arguments * @throws InvocationTargetException * Thrown if the method is not accessible */ private PerformanceJUnitStatement getStatement(final FrameworkMethod currentMethod) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { try { final Object testObject = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); if (classFinished){ return null; } LOG.debug("Statement: " + currentMethod.getName() + " " + classFinished); Statement testExceptionTimeoutStatement = methodInvoker(currentMethod, testObject); testExceptionTimeoutStatement = possiblyExpectingExceptions(currentMethod, testObject, testExceptionTimeoutStatement); // testExceptionTimeoutStatement = withPotentialTimeout(currentMethod, test, testExceptionTimeoutStatement); final Method withRulesMethod = BlockJUnit4ClassRunner.class.getDeclaredMethod("withRules", FrameworkMethod.class, Object.class, Statement.class); withRulesMethod.setAccessible(true); final Statement withRuleStatement = (Statement) withRulesMethod.invoke(this, new Object[] { currentMethod, testObject, testExceptionTimeoutStatement }); final PerformanceJUnitStatement perfStatement = new PerformanceJUnitStatement(withRuleStatement, testObject); final List<FrameworkMethod> befores = getTestClass().getAnnotatedMethods(Before.class); final List<FrameworkMethod> afters = getTestClass().getAnnotatedMethods(After.class); perfStatement.setBefores(befores); perfStatement.setAfters(afters); return perfStatement; } catch (final Throwable e) { return new PerformanceFail(e); } }
/** * Creates a new test instance * * @return new instance */ private Object newTestInstance() { try { return new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (final Throwable e) { return new Fail(e); } }
/** * Returns a Statement that, when executed, either returns normally if * {@code method} passes, or throws an exception if {@code method} fails. * * Here is an outline of the default implementation: * * <ul> * <li>Invoke {@code method} on the result of {@code createTest()}, and * throw any exceptions thrown by either operation. * <li>HOWEVER, if {@code method}'s {@code @Test} annotation has the {@code * expecting} attribute, return normally only if the previous step threw an * exception of the correct type, and throw an exception otherwise. * <li>HOWEVER, if {@code method}'s {@code @Test} annotation has the {@code * timeout} attribute, throw an exception if the previous step takes more * than the specified number of milliseconds. * <li>ALWAYS run all non-overridden {@code @Before} methods on this class * and superclasses before any of the previous steps; if any throws an * Exception, stop execution and pass the exception on. * <li>ALWAYS run all non-overridden {@code @After} methods on this class * and superclasses after any of the previous steps; all After methods are * always executed: exceptions thrown by previous steps are combined, if * necessary, with exceptions from After methods into a * {@link org.junit.runners.model.MultipleFailureException}. * <li>ALWAYS allow {@code @Rule} fields to modify the execution of the * above steps. A {@code Rule} may prevent all execution of the above steps, * or add additional behavior before and after, or modify thrown exceptions. * For more information, see {@link org.junit.rules.TestRule} * </ul> * * This can be overridden in subclasses, either by overriding this method, * or the implementations creating each sub-statement. */ protected Statement methodBlock(FrameworkMethod method) { Object test; try { test = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable e) { return new Fail(e); } Statement statement = methodInvoker(method, test); statement = possiblyExpectingExceptions(method, test, statement); statement = withPotentialTimeout(method, test, statement); statement = withBefores(method, test, statement); statement = withAfters(method, test, statement); statement = withRules(method, test, statement); return statement; }
@Override @SuppressWarnings("deprecation") protected Statement methodBlock(FrameworkMethod method) { Object test; try { test = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable e) { return new Fail(e); } boolean validated = true; for (CdhServer cdhServer : getTestClass().getAnnotatedFieldValues(test, ClassRule.class, CdhServer.class)) { validated = validated && cdhServer.isValid(); if (validated) { for (CdhServer cdhServerDependency : cdhServer.getDependencies()) { validated = validated && cdhServerDependency.isValid(); } } } Statement statement; if (validated) { statement = methodInvoker(method, test); statement = withLogging(method, test, statement); statement = possiblyExpectingExceptions(method, test, statement); statement = withPotentialTimeout(method, test, statement); statement = withBefores(method, test, statement); statement = withAfters(method, test, statement); statement = withServerRules(method, test, statement); statement = withRules(method, test, statement); } else { statement = new Statement() { @Override public void evaluate() throws Throwable { if (LOG.isWarnEnabled()) { LOG.warn("Skipping [" + method.getDeclaringClass().getCanonicalName() + "." + method.getName() + "], invalid classpath"); } } }; } return statement; }
/** * Returns a Statement that, when executed, either returns normally if * {@code method} passes, or throws an exception if {@code method} fails. * * Here is an outline of the default implementation: * * <ul> * <li>Invoke {@code method} on the result of {@code createTest()}, and * throw any exceptions thrown by either operation. * <li>HOWEVER, if {@code method}'s {@code @Test} annotation has the {@code * expecting} attribute, return normally only if the previous step threw an * exception of the correct type, and throw an exception otherwise. * <li>HOWEVER, if {@code method}'s {@code @Test} annotation has the {@code * timeout} attribute, throw an exception if the previous step takes more * than the specified number of milliseconds. * <li>ALWAYS run all non-overridden {@code @Before} methods on this class * and superclasses before any of the previous steps; if any throws an * Exception, stop execution and pass the exception on. * <li>ALWAYS run all non-overridden {@code @After} methods on this class * and superclasses after any of the previous steps; all After methods are * always executed: exceptions thrown by previous steps are combined, if * necessary, with exceptions from After methods into a * {@link MultipleFailureException}. * <li>ALWAYS allow {@code @Rule} fields to modify the execution of the * above steps. A {@code Rule} may prevent all execution of the above steps, * or add additional behavior before and after, or modify thrown exceptions. * For more information, see {@link TestRule} * </ul> * * This can be overridden in subclasses, either by overriding this method, * or the implementations creating each sub-statement. */ protected Statement methodBlock(FrameworkMethod method) { Object test; try { test = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable e) { return new Fail(e); } Statement statement = methodInvoker(method, test); statement = possiblyExpectingExceptions(method, test, statement); statement = withPotentialTimeout(method, test, statement); statement = withBefores(method, test, statement); statement = withAfters(method, test, statement); statement = withRules(method, test, statement); return statement; }
/** * Returns a Statement that, when executed, either returns normally if * {@code method} passes, or throws an exception if {@code method} fails. * <p/> * Here is an outline of the default implementation: * <p/> * <ul> * <li>Invoke {@code method} on the result of {@code createTest()}, and * throw any exceptions thrown by either operation. * <li>HOWEVER, if {@code method}'s {@code @Test} annotation has the {@code * expecting} attribute, return normally only if the previous step threw an * exception of the correct type, and throw an exception otherwise. * <li>HOWEVER, if {@code method}'s {@code @Test} annotation has the {@code * timeout} attribute, throw an exception if the previous step takes more * than the specified number of milliseconds. * <li>ALWAYS run all non-overridden {@code @Before} methods on this class * and superclasses before any of the previous steps; if any throws an * Exception, stop execution and pass the exception on. * <li>ALWAYS run all non-overridden {@code @After} methods on this class * and superclasses after any of the previous steps; all After methods are * always executed: exceptions thrown by previous steps are combined, if * necessary, with exceptions from After methods into a * {@link org.junit.runners.model.MultipleFailureException}. * <li>ALWAYS allow {@code @Rule} fields to modify the execution of the * above steps. A {@code Rule} may prevent all execution of the above steps, * or add additional behavior before and after, or modify thrown exceptions. * For more information, see {@link org.junit.rules.TestRule} * </ul> * <p/> * This can be overridden in subclasses, either by overriding this method, * or the implementations creating each sub-statement. */ protected Statement methodBlock(FrameworkMethod method) { Object test; try { test = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable e) { return new Fail(e); } Statement statement = methodInvoker(method, test); statement = possiblyExpectingExceptions(method, test, statement); statement = withPotentialTimeout(method, test, statement); statement = withBefores(method, test, statement); statement = withAfters(method, test, statement); statement = withRules(method, test, statement); return statement; }