All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.jqwik.spring.AroundSpringTestContainer Maven / Gradle / Ivy

There is a newer version: 0.12.0
Show newest version
package net.jqwik.spring;

import java.lang.reflect.*;
import java.util.*;

import net.jqwik.api.lifecycle.*;

class AroundSpringTestContainer implements BeforeContainerHook, AfterContainerHook {

	@Override
	public boolean appliesTo(Optional optionalElement) {
		// Only apply to container classes
		return optionalElement.map(element -> element instanceof Class).orElse(false);
	}

	@Override
	public void beforeContainer(ContainerLifecycleContext context) throws Exception {
		Optional> optionalContainerClass = context.optionalContainerClass();
		if (optionalContainerClass.isPresent()) {
			JqwikSpringExtension.getTestContextManager(optionalContainerClass.get()).beforeTestClass();
		}
	}

	@Override
	public void afterContainer(ContainerLifecycleContext context) throws Exception {
		Optional> optionalContainerClass = context.optionalContainerClass();
		if (optionalContainerClass.isPresent()) {
			JqwikSpringExtension.getTestContextManager(optionalContainerClass.get()).afterTestClass();
		}
	}

	@Override
	public int beforeContainerProximity() {
		return -20;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy