对于我的一个Spring bean(比如Application类),我使用@Value注释从属性文件(prop.properties)中获取属性的值(my.property.flag = true/false).这完全没问题.
我需要编写一个集成测试(比如说ApplicationIt类),我需要测试属性的值,即true和false.
在我的属性文件中,属性的值设置为true.是否可以从我的Integration测试中将值动态设置为false?
例如,
prop.properties:
my.property.flag=true
Run Code Online (Sandbox Code Playgroud)
应用程序类文件:
@Component
class Application {
//This value is fetched from properties file
//the value is set to true.
@Value(${my.property.flag})
private String isTrue;
......
..........
}
Run Code Online (Sandbox Code Playgroud)
整合测试:
class ApplicationIT {
//how can I set the value of isTrue here to false?
}
Run Code Online (Sandbox Code Playgroud)