@Override public void interceptInitializerMethod(IMethodInvocation invocation) throws Throwable { injectValues(invocation.getInstance(), false, (Specification)invocation.getInstance()); invocation.proceed(); }
@Override public void interceptSetupSpecMethod(IMethodInvocation invocation) throws Throwable { listener.beforeTestClass(invocation.getSharedInstance().getClass()); invocation.proceed(); }
@Override public void interceptSetupMethod(IMethodInvocation invocation) throws Throwable { exception = null; beforeTestMethodInvoked = true; manager.beforeTestMethod(invocation.getInstance(), invocation.getFeature().getFeatureMethod().getReflection()); invocation.proceed(); }
@Override public void evaluate() throws Throwable { invocation.proceed(); } };
@Override public void interceptSharedInitializerMethod(IMethodInvocation invocation) throws Throwable { createInjector(); injectValues(invocation.getSharedInstance(), true, (Specification)invocation.getInstance()); invocation.proceed(); }
@Override public void interceptFeatureMethod(IMethodInvocation invocation) throws Throwable { Throwable throwable = null; listener.beforeTestMethod(invocation.getInstance(), invocation.getMethod().getReflection()); try { invocation.proceed(); } catch (Throwable t) { throwable = t; throw t; } finally { listener.afterTestMethod(invocation.getInstance(), invocation.getMethod().getReflection(), throwable); } }
@Override public void intercept(final IMethodInvocation invocation) throws Throwable { Statement stat = createBaseStatement(invocation); for (FieldInfo field : ruleFields) { TestRule rule = (TestRule) getRuleInstance(field, field.isShared() ? invocation.getSharedInstance() : invocation.getInstance()); stat = rule.apply(stat, invocation.getSpec().getDescription()); } stat.evaluate(); } }
@Override public void intercept(IMethodInvocation invocation) throws Throwable { AtomicBoolean pass = new AtomicBoolean(false); invocation.getFeature().getFeatureMethod().addInterceptor( new InnerIterationInterceptor(pass, expectedExceptions, reason)); invocation.proceed(); if (pass.get()) { throw assumptionViolation(); } else { throw featurePassedUnexpectedly(); } }
/** * Returns the current {@code Specification} instance. * * @return the current {@code Specification} instance */ public Object getInstance() { return invocation.getInstance(); }
@Override public void intercept(final IMethodInvocation invocation) throws Throwable { Statement stat = createBaseStatement(invocation); for (FieldInfo field : ruleFields) { TestRule rule = (TestRule) getRuleInstance(field, invocation.getInstance()); stat = rule.apply(stat, invocation.getIteration().getDescription()); } stat.evaluate(); } }
@Override public void interceptSetupMethod(IMethodInvocation invocation) throws Throwable { log.fine("before " + invocation.getFeature().getFeatureMethod().getReflection().getName()); getTestRunner().before(invocation.getTarget(), invocation.getFeature().getFeatureMethod().getReflection(), new InvocationExecutor(invocation)); }
@Override public Method getMethod() { return invocation.getFeature().getFeatureMethod().getReflection(); }
@Override public void interceptSetupSpecMethod(IMethodInvocation invocation) throws Throwable { Class<?> specClass = invocation.getSpec().getReflection(); log.fine("beforeClass " + specClass.getName()); getTestRunner().beforeClass(specClass, new InvocationExecutor(invocation)); }
startLatch.await(5, TimeUnit.SECONDS); } catch (InterruptedException ignored) { System.out.printf("[spock.lang.Timeout] Could not sync with Feature for method '%s'", invocation.getMethod().getName()); waitMillis *= 2; System.out.printf("[spock.lang.Timeout] Method '%s' has not yet returned - interrupting. Next try in %1.2f seconds.\n", invocation.getMethod().getName(), waitMillis / 1000.);
public Void doCall(Object[] args) throws Throwable { invocation.proceed(); return null; } });
@Override public void interceptSharedInitializerMethod(IMethodInvocation invocation) throws Throwable { createInjector(); injectValues(invocation.getSharedInstance(), true, (Specification)invocation.getInstance()); invocation.proceed(); }
@Override public void intercept(IMethodInvocation invocation) throws Throwable { List<Throwable> throwableList = new ArrayList<>(); for (int i = 0; i <= retry.count(); i++) { Queue<Throwable> throwables = new ConcurrentLinkedQueue<>(); invocation.getFeature().getFeatureMethod().addInterceptor(new InnerRetryInterceptor(retry, condition, throwables)); invocation.proceed(); if (throwables.isEmpty()) { throwableList.clear(); break; } else { throwableList.addAll(throwables); if (retry.delay() > 0) Thread.sleep(retry.delay()); } } if (!throwableList.isEmpty()) { throw new MultipleFailureException(throwableList); } }
final CountDownLatch startLatch = new CountDownLatch(2); new Thread(String.format("[spock.lang.Timeout] Watcher for method '%s'", invocation.getMethod().getName())) { @Override public void run() { startLatch.await(5, TimeUnit.SECONDS); } catch (InterruptedException ignored) { System.out.printf("[spock.lang.Timeout] Could not sync with Watcher for method '%s'", invocation.getMethod().getName()); invocation.proceed(); } catch (Throwable t) { saved = t;
@Override public void intercept(final IMethodInvocation invocation) throws Throwable { DefaultGroovyMethods.use(null, categories, new Closure<Void>(invocation.getInstance(), invocation.getInstance()) { public Void doCall(Object[] args) throws Throwable { invocation.proceed(); return null; } }); } }