我被擊中的問題是斯波克不允許嘲弄的規範之外創建 - How to create Spock mocks outside of a specification class?測試的模擬豆春與斯波克
這似乎仍然懸而未決所以要問的是,給我有一個複雜和嵌套的DI圖什麼是在圖中深入「模擬」表示的最有效方式?
理想情況下,我有一個bean定義爲正常部署設置和另一個運行時,單元測試,它是該定義集作爲適用嘲笑
例如
@Configuration
@Profile("deployment")
public class MyBeansForDeployment {
@Bean
public MyInterface myBean() {
return new MyConcreateImplmentation();
}
}
& &
@Configuration
@Profile("test")
public class MyBeansForUnitTests {
@Bean
public MyInterface myBean() {
return new MyMockImplementation();
}
}