如果我进行集成测试,您能告诉我原因吗:
@TestPropertySource(properties = {"spring.application.environment=dev"})
@SpringBootTest
class IntegrationTest {
@Autowired
PropertyConfig propertyConfig;
@Nested
@SpringBootTest
@TestPropertySource(properties = {"spring.application.environment=dev", "spring.application.property=example"})
class ServerLoadConfiguration {
@Test
void exampleTest() {
String someProperty = propertyConfig.getSomeProperty(); // old value
....
}
}
例如,测试I从“默认”属性中获取属性值,而不是用@TestPropertySource www.example.com中指定的一个属性覆盖spring.application.property?
如果我在IntegrationTest级别上设置@TestPropertySource(properties = {"spring.application.environment=dev", "spring.application.property=example"})
,则嵌套类将应用此值。
1条答案
按热度按时间e37o9pze1#
抱歉,无法重现,使用:
1.使用简单(st)快速启动器
1.简单(java〉16)道具:
1.简单(st)配置:
1.测试:
1.遍数(作为“单元”作为“集成”):