use of spock.lang.AutoCleanup in project spock by spockframework.
the class AutoCleanupInterceptor method intercept.
public void intercept(IMethodInvocation invocation) throws Throwable {
List<Throwable> exceptions = new ArrayList<Throwable>();
try {
invocation.proceed();
} catch (Throwable t) {
exceptions.add(t);
}
for (FieldInfo field : fields) {
AutoCleanup annotation = field.getAnnotation(AutoCleanup.class);
try {
Object value = field.readValue(invocation.getInstance());
if (value == null)
continue;
GroovyRuntimeUtil.invokeMethod(value, annotation.value());
} catch (Throwable t) {
if (!annotation.quiet())
exceptions.add(t);
}
}
ExtensionUtil.throwAll(exceptions);
}
Aggregations