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

net.jqwik.engine.discovery.specs.GroupDiscoverySpec 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 GroupDiscoverySpec implements DiscoverySpec> {

	private final static Predicate> isPotentialTestContainer = new IsPotentialTestContainer();
	private final static Predicate> isTopLevelClass = new IsTopLevelClass();
	private final static Predicate> hasGroupAnnotation = candidate -> candidate.isAnnotationPresent(Group.class);

	@Override
	public boolean shouldBeDiscovered(Class candidate) {
		return isPotentialTestContainer
			.and(isTopLevelClass.negate())
			.and(hasGroupAnnotation)
			.test(candidate);
	}
	@Override
	public SkipResult shouldBeSkipped(Class candidate) {
		if (isStatic(candidate))
			return SkipResult.skip("@Group classes must not be static");
		return SkipResult.doNotSkip();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy