当特定弹簧配置文件处于活动状态时如何防止运行测试? [英] How to prevent running tests when specific spring profile is active?
本文介绍了当特定弹簧配置文件处于活动状态时如何防止运行测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个基于 Maven 构建的 Spring Boot 应用程序.我正在使用 Spring 配置文件来区分特定于环境的配置.当特定的 Spring 配置文件处于活动状态时,我想阻止运行测试.原因:我想阻止使用生产属性 (spring.profiles.active=prod
) 运行测试.我想在全局范围内执行此操作(可能使用一些 Maven 插件),而不是分别在每个测试中执行.
I have a Spring Boot application build on Maven. I'm using Spring profiles to distinguish environment-specific configuration. I would like to prevent running tests when a specific Spring profile is active. Reason: I would like to prevent running tests with production properties (spring.profiles.active=prod
). I would like to do this globally (maybe with some Maven plugin) instead of on each test separately.
您有任何经过验证的解决方案吗?
Do you have any checked solutions for this?
推荐答案
<profiles>
<profile>
<id>prod</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
</profiles>
这篇关于当特定弹簧配置文件处于活动状态时如何防止运行测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文