Java @TestPropertySource(properties={";ticketing.profile=test";})是否应该自动更新系统属性值?

Java @TestPropertySource(properties={";ticketing.profile=test";})是否应该自动更新系统属性值?,java,spring,spring-boot,Java,Spring,Spring Boot,我正在使用SpringBoot和com.springweb.tester包创建测试。 我有一个测试类,它是这样开始的: @RunWith(SpringRunner.class) @TestPropertySource(properties = {"ticketing.profile=test"}) @SpringBootTest(classes = TicketingConfiguration.class, webEnvironment = SpringBootTest.WebEnvironme

我正在使用SpringBoot和com.springweb.tester包创建测试。 我有一个测试类,它是这样开始的:

@RunWith(SpringRunner.class)
@TestPropertySource(properties = {"ticketing.profile=test"})
@SpringBootTest(classes = TicketingConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class TicketingControllerTest extends BaseControllerTest {
....
}
我的理解是

System.getProperty("ticketing.profile")
在其中一个测试方法中(特别是在重写的testInit()方法中),返回“test”是否合乎逻辑

对我来说,它返回null

谢谢

@TestPropertySource(properties = {"ticketing.profile=test"}) 
不会影响系统属性
ticketing.profile

代码不应使用system属性获取值,因为这意味着您无法重写它

代码应该使用spring属性获取程序,如果找不到,它可以遵从系统属性

典型的方法是在代码中设置默认属性(或在测试中设置默认属性),然后通过设置系统属性覆盖它