我一直在使用Spring中@Configuration支持创建我嘲笑的Mockito在JUnit的使用测试春天的Mockito 3.1集成
@Configuration
public class MockAppContextHelper {
@Bean
public IntegrationServerServiceWrapper integrationServerServiceWrapperTest() {
return mock(IntegrationServerServiceWrapper.class);
}
}
这曾经在Spring 3.0.2做工精细。
在Spring 3.1,我得到以下错误:org.springframework.beans.factory.BeanCreationException:由 造成错误创建名为“integrationServerServiceWrapperTest”在类路径资源定义[COM/KN/BPA /任务/服务豆/impl/MockAppContextHelper.class]:找不到匹配的工厂方法:factory bean'mockAppContextHelper';工厂方法'integrationServerServiceWrapperTest()'。检查具有指定名称的方法是否存在并且它是非静态的。
任何想法?
感谢您的支持
我从来没有内置模拟以这种方式(使用@Configuration和@Bean),我不知道你错误的原因是什么,但你可以看看项目[Springockito](https://bitbucket.org/kubek2k/springockito/wiki/Home)这大大简化了在Spring环境中创建模拟。 – 2012-04-09 21:04:41