java - Spring Boot 集成测试覆盖自定义 .properties 文件
问题描述
我正在实施集成测试,但在覆盖我的应用程序使用的自定义属性时遇到了问题。
集成测试样本:
@RunWith(SpringRunner.class)
@SpringBootTest(
classes = Application.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
)
@TestPropertySource(locations = "classpath:test.properties")
public abstract class BaseIntegrationTest {
@Autowired
protected TestRestTemplate restClient;
将使用提供的应用程序@TestPropertySource(locations = "classpath:test.properties")
覆盖application.properties
我的应用程序
但是,我的应用程序使用这样的自定义属性文件:
@Configuration
@PropertySource("classpath:fileProvider/custom.properties")
@ConfigurationProperties(prefix = "com.sample.config")
public class SampleProviderConfigProperties {
在我的应用程序中有许多外部提供商。他们每个人都喜欢SampleProviderConfigProperties
有自己的配置
在集成测试中,我想custom.properties
用测试系统的配置替换提供者。
有没有办法做到这一点?
解决方案
推荐阅读
- python - 如何将文本保留在 pygame 窗口上一段确定的时间
- reactjs - 在 MERN 堆栈中工作时初始化 Reducer 时出错
- c# - 有经验的 DBA 应该使用哪种 C# 操作 ms-access 的方法?
- ionic-framework - 我想更改 ionic 中的复选框图标
- javascript - How to chain API calls in rxJs subscribe and map with Angular?
- html - 如何响应将标题/顶部导航中的元素对齐到中心
- c# - 启动线程后 UI 冻结
- node.js - 如何发出获取请求
快递中的头部请求? - tensorflow - 如何在 Vespa 中保护 Tensorflow?
- c# - C# WinForms 线程管理器