net.jqwik.engine.hooks.lifecycle.PropertyLifecycleMethodsHook Maven / Gradle / Ivy
The newest version!
package net.jqwik.engine.hooks.lifecycle;
import java.lang.reflect.*;
import java.util.*;
import org.junit.platform.engine.support.hierarchical.*;
import net.jqwik.api.lifecycle.*;
import net.jqwik.engine.execution.lifecycle.*;
import net.jqwik.engine.hooks.*;
import net.jqwik.engine.support.*;
public class PropertyLifecycleMethodsHook implements AroundPropertyHook {
private void beforeProperty(PropertyLifecycleContext context) {
List beforeContainerMethods = LifecycleMethods.findBeforePropertyMethods(context.containerClass());
callPropertyMethods(beforeContainerMethods, context);
}
private void callPropertyMethods(List methods, PropertyLifecycleContext context) {
ThrowableCollector throwableCollector = new ThrowableCollector(ignore -> false);
for (Method method : methods) {
Object[] parameters = MethodParameterResolver.resolveParameters(method, context);
throwableCollector.execute(() -> callMethod(method, context.testInstances(), parameters));
}
throwableCollector.assertEmpty();
}
private void callMethod(Method method, List