2012-03-13 101 views
1

我一直在使用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()'。檢查具有指定名稱的方法是否存在並且它是非靜態的。

任何想法?

感謝您的支持

+0

我從來沒有內置模擬以這種方式(使用@Configuration和@Bean),我不知道你錯誤的原因是什麼,但你可以看看項目[Springockito](https://bitbucket.org/kubek2k/springockito/wiki/Home)這大大簡化了在Spring環境中創建模擬。 – 2012-04-09 21:04:41

回答