【发布时间】:2017-01-25 21:16:56
【问题描述】:
我正在为我的应用程序编写集成测试,并希望为我的测试使用自定义 webmvc 配置
我的基础包 com.marco.nutri 中有三个类:
- 应用程序(使用@SpringBootApplication注解)
- MvcConfig(@Configuration 和@EnableWebMVC)
- SecurityConfig(@Configuration 和 @EnableWebSecurity)
我的测试在包 br.com.marco.nutri.integration.auth 中:
@RunWith(SpringRunner.class)
@SpringBootTest(classes={Application.class, WebMvcTestConfiguration.class, SecurityConfig.class})
public class ITSignup {
//Test code
}
我在 com.marco.nutri.integration 包中有一个测试配置类:
@TestConfiguration
@EnableWebMvc
public class WebMvcTestConfiguration extends WebMvcConfigurerAdapter {
//Some configuration
}
但是当我运行测试时,选择的是 MvcConfig.class 而不是 WebMvcTestConfiguration.class
我做错了什么?
【问题讨论】:
标签: java spring spring-boot spring-test