private void registerSpy(ConfigurableListableBeanFactory beanFactory,
                           BeanDefinitionRegistry registry, SpyDefinition definition) {
    Set<String> existingBeans = getExistingBeans(beanFactory, definition.getTypeToSpy());
    if (ObjectUtils.isEmpty(existingBeans)) {
      FieldInfo fieldInfo = definition.getFieldInfo();
      throw new SpringExtensionException(String.format("No matching bean found! " +
        "@SpringSpy requires an existing spring bean to wrap, to create a standalone spy use @SpringBean.%n" +
        "Offending Field: '%s.%s:%d'", fieldInfo.getParent().getName(), fieldInfo.getName(), fieldInfo.getLine()));
    } else {
      registerSpies(registry, definition, existingBeans);
    }
  }
Factory method used by defined beans to actually create the mock.

@param mockDefinition the mock definition
@param name the bean name
@return the mock instance
spock-spring/src/main/java/org/spockframework/spring/mock/SpockMockPostprocessor.java