9
1つ以上の統合テストでSpring構成の単一のBeanまたは値を置き換える可能性はありますか?私の場合はテスト用のJavaベースのSpringコンテキスト設定を上書きする
、私は
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MyIntegrationTestConfig.class, loader = SpringApplicationContextLoader.class)
public class MyIntegrationTest {
// do the tests
}
は、今私は私がで1つのBeanを交換する統合テストの第2のセットを持つようにしたい私の統合テストのために使用される構成
@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages = {"foo.bar"})
public class MyIntegrationTestConfig {
// everything done by component scan
}
を持っています別のもの。
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MyIntegrationTestConfig.class, loader = SpringApplicationContextLoader.class)
public class MySpecialIntegrationTest {
// influence the context configuration such that a bean different from the primary is loaded
// do the tests using the 'overwritten' bean
}
これを達成する最も簡単な方法は何ですか?