/** * Perform the same logic as * {@link BlockJUnit4ClassRunner#runChild(FrameworkMethod, RunNotifier)}, * except that tests are determined to be <em>ignored</em> by * {@link #isTestMethodIgnored(FrameworkMethod)}. */ @Override protected void runChild(FrameworkMethod frameworkMethod, RunNotifier notifier) { Description description = describeChild(frameworkMethod); if (isTestMethodIgnored(frameworkMethod)) { notifier.fireTestIgnored(description); } else { Statement statement; try { statement = methodBlock(frameworkMethod); } catch (Throwable ex) { statement = new Fail(ex); } runLeaf(statement, description, notifier); } }
return new Fail(ex);
return new Fail(e);
return new Fail(e);
if (someError) return new Fail(1); else return new Okay(true);
/** * Get current test object * * @return test object. */ public Object getTestObject() { Object testObject = testObjectMap.get(getTestClass()); if (testObject == null) { try { ReflectiveCallable reflectiveCallable = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }; testObject = reflectiveCallable.run(); testObjectMap.put(getTestClass(), testObject); } catch (Throwable e) { return new Fail(e); } } return testObject; }
/** * Override to avoid running Before, After and Rule methods by the driver. They shall only be * run by the container when using a probe invoker. */ protected Statement methodBlock(FrameworkMethod method) { Object test; try { ReflectiveCallable reflectiveCallable = new ReflectiveCallable() { @Override // CHECKSTYLE:SKIP : Base class API protected Object runReflectiveCall() throws Throwable { return createTest(); } }; test = reflectiveCallable.run(); } // CHECKSTYLE:SKIP : ReflectiveCallable API catch (Throwable e) { return new Fail(e); } Statement statement = methodInvoker(method, test); return statement; }
/** * Override to avoid running Before, After and Rule methods by the driver. They shall only be * run by the container when using a probe invoker. */ @Override protected Statement methodBlock(FrameworkMethod method) { Object test; try { ReflectiveCallable reflectiveCallable = new ReflectiveCallable() { @Override // CHECKSTYLE:SKIP : Base class API protected Object runReflectiveCall() throws Throwable { return createTest(); } }; test = reflectiveCallable.run(); } // CHECKSTYLE:SKIP : ReflectiveCallable API catch (Throwable e) { return new Fail(e); } Statement statement = methodInvoker(method, test); return statement; }
return new Fail(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); } }
/** * 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); } }
public Statement createStatement(final TestClass testClass, final FrameworkMethod method, final Object target, final Statement next, final Description description, final RunNotifier notifier) { Statement statement = next; try { for (Object instance = target; instance != null; instance = getEnclosingInstance(instance)) { final TestClass instanceTestClass = TestClassPool.forClass(instance.getClass()); final List<FrameworkMethod> afterMethods = instanceTestClass.getAnnotatedMethods(After.class); statement = afterMethods.isEmpty() ? statement : new RunAfters(statement, afterMethods, instance); } } catch (final IllegalAccessException e) { statement = new Fail(e); } return statement; } }
public Statement createStatement(final TestClass testClass, final FrameworkMethod method, final Object target, final Statement next, final Description description, final RunNotifier notifier) { Statement statement = next; try { for (Object instance = target; instance != null; instance = getEnclosingInstance(instance)) { final TestClass instanceTestClass = TestClassPool.forClass(instance.getClass()); final List<FrameworkMethod> beforeMethods = instanceTestClass.getAnnotatedMethods(Before.class); statement = beforeMethods.isEmpty() ? statement : new RunBefores(statement, beforeMethods, instance); } } catch (final IllegalAccessException e) { statement = new Fail(e); } return statement; } }
@Override protected Statement methodBlock(FrameworkMethod method) { if (!useDelegate) { return super.methodBlock(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); return statement; }
public void run(final TestClass testClass, final Class<?> clazz, final RunNotifier notifier) { try { new HierarchicalContextRunner(clazz).run(notifier); } catch (final Throwable t) { statementExecutor.execute(new Fail(t), notifier, describer.describe(clazz)); } } }
/** * Perform the same logic as * {@link BlockJUnit4ClassRunner#runChild(FrameworkMethod, RunNotifier)}, * except that tests are determined to be <em>ignored</em> by * {@link #isTestMethodIgnored(FrameworkMethod)}. */ @Override protected void runChild(FrameworkMethod frameworkMethod, RunNotifier notifier) { Description description = describeChild(frameworkMethod); if (isTestMethodIgnored(frameworkMethod)) { notifier.fireTestIgnored(description); } else { Statement statement; try { statement = methodBlock(frameworkMethod); } catch (Throwable ex) { statement = new Fail(ex); } runLeaf(statement, description, notifier); } }
@SuppressWarnings("deprecation") protected Statement methodBlock(FrameworkMethod method, Param<P> param) { Object test; try { test = Util.reflectCall(this::createTest); } catch (Throwable e) { return new Fail(e); } Statement statement = methodInvoker(method, test, param); 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; }
@SuppressWarnings("deprecation") protected Statement methodBlock(FrameworkMethod method, RunNotifier notifier) { Object test; try { test = new ReflectiveCallable() { @Override protected Object runReflectiveCall() throws Throwable { return createTest(); } }.run(); } catch (Throwable e) { // NOSONAR return new Fail(e); } Statement statement = methodInvoker2(method, test, notifier); statement = possiblyExpectingExceptions(method, test, statement); statement = withPotentialTimeout(method, test, statement); statement = this.withBefores(method, test, statement, notifier); statement = this.withAfters(method, test, statement, notifier); statement = withRules(method, 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; }
public void run(final TestClass testClass, final FrameworkMethod method, final RunNotifier notifier) { final Description description = describer.describe(method); if (method.getAnnotation(Ignore.class) != null) { notifier.fireTestIgnored(description); } else { try { final Stack<Class<?>> classHierarchy = getClassHierarchy(testClass.getJavaClass()); final Object target = createDeepInstance(classHierarchy); Statement statement = buildStatement(testClass, method, target, description, notifier); for (final MethodStatementBuilder builder : statementBuilders) { statement = builder.createStatement(testClass, method, target, statement, description, notifier); } statementExecutor.execute(statement, notifier, description); } catch (Throwable t) { statementExecutor.execute(new Fail(t), notifier, description); } } }