【发布时间】:2019-02-12 14:13:46
【问题描述】:
想用 application-test.properties 为我的 junit 完全替换我的 application.properties。
TestPropertySource 没有做这项工作。似乎它只替换了一些常见的属性,但我不想要。
想在我的 Junit \ 集成测试中加载 application-test.properties 而不是 application.properties。
@RunWith(SpringRunner.class)
@ActiveProfiles( "test" )
@SpringBootTest(classes = Application.class)
@TestPropertySource(locations="classpath:application-test.properties")
@AutoConfigureMockMvc
【问题讨论】:
-
不要以
@SpringBootTest运行它,而是构建您自己的弹簧配置测试。 -
但我仍然只使用
@ActiveProfiles( "test" )
标签: java spring spring-boot spring-boot-test