use of org.spockframework.runtime.model.SpecInfo in project spock by spockframework.
the class TapestryExtension method collectModules.
// Returns null if no SubModule annotation was found.
// Returns an empty list if one or more SubModule annotations were found,
// but they didn't specify any modules. This distinction is important to
// allow activation of the extension w/o specifying any modules.
private Set<Class<?>> collectModules(SpecInfo spec) {
Set<Class<?>> modules = null;
for (SpecInfo curr : spec.getSpecsTopToBottom()) {
SubModule subModule = curr.getAnnotation(SubModule.class);
if (subModule == null)
continue;
if (modules == null)
modules = new HashSet<Class<?>>();
modules.addAll(Arrays.<Class<?>>asList(subModule.value()));
}
return modules;
}
use of org.spockframework.runtime.model.SpecInfo in project ratpack by ratpack.
the class TempDirExtension method visitFieldAnnotation.
@Override
public void visitFieldAnnotation(TempDir annotation, FieldInfo field) {
Class<?> fieldType = field.getType();
if (!fieldType.isAssignableFrom(TemporaryFolder.class)) {
throw new InvalidSpecException("@TempDir can only be used on TemporaryFolder");
}
TempDirInterceptor interceptor = new TempDirInterceptor(fieldType, field, configuration.baseDir, configuration.keep);
// attach interceptor
SpecInfo specInfo = field.getParent();
if (field.isShared()) {
specInfo.addInterceptor(interceptor);
} else {
for (FeatureInfo featureInfo : specInfo.getBottomSpec().getAllFeatures()) {
featureInfo.addIterationInterceptor(interceptor);
}
}
}
use of org.spockframework.runtime.model.SpecInfo in project spock by spockframework.
the class ClassSelectorResolver method resolveClass.
private Resolution resolveClass(Class<?> specClass, Context context) {
if (SpecUtil.isRunnableSpec(specClass) && classNameFilter.test(specClass.getName())) {
return context.addToParent(parent -> {
SpecInfo specInfo = new SpecInfoBuilder(specClass).build();
specInfo.getAllFeatures().forEach(featureInfo -> featureInfo.setExcluded(true));
UniqueId uniqueId = parent.getUniqueId().append("spec", specInfo.getReflection().getName());
return Optional.of(new SpecNode(uniqueId, runContext.getConfiguration(RunnerConfiguration.class), specInfo));
}).map(this::toResolution).orElse(Resolution.unresolved());
}
return Resolution.unresolved();
}
use of org.spockframework.runtime.model.SpecInfo in project spock by spockframework.
the class TapestryInterceptor method findAllBeforeRegistryCreatedMethods.
private List<Method> findAllBeforeRegistryCreatedMethods() {
List<Method> methods = new ArrayList<Method>();
for (SpecInfo curr : spec.getSpecsTopToBottom()) {
Method method = ReflectionUtil.getDeclaredMethodByName(curr.getReflection(), "beforeRegistryCreated");
if (method != null) {
method.setAccessible(true);
methods.add(method);
}
}
return methods;
}
use of org.spockframework.runtime.model.SpecInfo in project dropwizard-guicey by xvik.
the class AbstractAppExtension method visitSpec.
@Override
public void visitSpec(final SpecInfo spec) {
final GuiceyInterceptor interceptor = new GuiceyInterceptor(spec, buildResourceFactory(annotation));
final SpecInfo topSpec = spec.getTopSpec();
topSpec.addSharedInitializerInterceptor(interceptor);
topSpec.addInitializerInterceptor(interceptor);
topSpec.addCleanupSpecInterceptor(interceptor);
}
Aggregations