测试上下文上的@EnableAutoConfiguration

时间:2019-07-03 08:33:22

标签: spring-boot testing spring-bean

我有一个项目正在开发spring自动配置模块。

我正在使用测试配置类(在测试类路径中), 在本课程中,我们使用@EnableAutoConfiguration

@Configuration
@EnableAutoConfiguration
public class MyTestContext {

}

在每个测试类中,我都通过以下方式使用它:

@ContextConfiguration(classes = {MyTestContext.class})

看起来上下文已正确创建并通过测试。

我的问题是: -在测试环境中使用@EnableAutoConfiguration是好的做法吗? -这样做的真正效果是什么?

0 个答案:

没有答案
相关问题