/** * 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; }
@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(); }