diff --git a/src/main/java/org/jbehavesupport/engine/discovery/JBehaveDiscoverer.java b/src/main/java/org/jbehavesupport/engine/discovery/JBehaveDiscoverer.java index e23dd52..a864096 100644 --- a/src/main/java/org/jbehavesupport/engine/discovery/JBehaveDiscoverer.java +++ b/src/main/java/org/jbehavesupport/engine/discovery/JBehaveDiscoverer.java @@ -27,6 +27,10 @@ import org.junit.platform.engine.support.descriptor.EngineDescriptor; import org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver; +import java.util.function.Predicate; + +import static java.lang.reflect.Modifier.isAbstract; + public class JBehaveDiscoverer { public EngineDescriptor discover(EngineDiscoveryRequest discoveryRequest, UniqueId uniqueId) { @@ -37,9 +41,21 @@ public EngineDescriptor discover(EngineDiscoveryRequest discoveryRequest, Unique private EngineDiscoveryRequestResolver getResolver(EngineDiscoveryRequest discoveryRequest, UniqueId engineId) { return EngineDiscoveryRequestResolver.builder() - .addClassContainerSelectorResolver(JUnit5Stories.class::isAssignableFrom) + .addClassContainerSelectorResolver(getJBehaveClassSelector()) .addSelectorResolver(new JBehaveSelectorResolver(discoveryRequest, engineId)) .build(); } + private static Predicate> getJBehaveClassSelector() { + return isCorrectClass().and(isNotAbstract()); + } + + private static Predicate> isNotAbstract() { + return clazz -> !isAbstract(clazz.getModifiers()); + } + + private static Predicate> isCorrectClass() { + return JUnit5Stories.class::isAssignableFrom; + } + }