我正在使用@TestPropertySource覆盖我的集成测试中的application.yml属性,以用于Spring启动应用程序。
@TestPropertySource(properties = { "repository.file.path=src/test/resources/x" })
我想知道是否有某种方法可以使属性VALUE动态化。像这样的东西:
@TestPropertySource(properties = { "repository.file.path=PropertyValueProvider.class" })
感谢您的反馈。在我的情况下,属性值是系统特定的,应该在测试运行时生成。
@TestPropertySource
仅提供用于配置PropertySource
s的声明性机制。 “参考手册”中的Documentation。
如果你需要编程支持将PropertySource
添加到Environment
,你应该实现一个可以通过ApplicationContextInitializer
注册的@ContextConfiguration(initializers = ...)
。 “参考手册”中的Documentation。
问候,
Sam(Spring TestContext Framework的作者)