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

net.jqwik.engine.discovery.specs.TopLevelContainerDiscoverySpec Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
package net.jqwik.engine.discovery.specs;

import java.util.function.*;

import org.junit.platform.engine.support.hierarchical.Node.*;

import net.jqwik.api.*;
import net.jqwik.engine.discovery.predicates.*;

import static org.junit.platform.commons.support.ModifierSupport.*;

public class TopLevelContainerDiscoverySpec implements DiscoverySpec> {

	private final static Predicate> isPotentialTestContainer = new IsPotentialTestContainer();
	private final static Predicate> isTopLevelClass = new IsTopLevelClass();
	private final static Predicate> isGroup = candidate -> candidate.isAnnotationPresent(Group.class);
	private final static Predicate> isStaticNonGroupMember = candidate -> isStatic(candidate) && !isGroup.test(candidate);

	@Override
	public boolean shouldBeDiscovered(Class candidate) {
		return isPotentialTestContainer
			.and(isTopLevelClass.or(isStaticNonGroupMember))
			.test(candidate);
	}

	@Override
	public SkipResult shouldBeSkipped(Class candidate) {
		return SkipResult.doNotSkip();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy