[英]how to preload a Serenity properties file configuration executing some java code before
我有一个带有 Serenity 属性文件配置的项目,我想在开始测试之前放一个安全代码,所以在开始准备测试时,我像这样清理值:
...
serenity.timeout=1000
secretVariable=
serenity.verbose.steps=FALSE
...
但是当我运行测试时,我想像这样更改 serenity.properties:
...
serenity.timeout=1000
secretVariable=24C20-00034D2
serenity.verbose.steps=FALSE
...
所以,我的问题是,这是否可以使用 java 代码和/或 maven 配置?
如果你想改变一些非配置文件的设置,我可能只提供springboot项目相关的配置,你可以设置你的vm选项:
--serenity.timeout=1000
--secretVariable=24C20-00034D2
--serenity.verbose.steps=FALSE
或者您可以修改启动的 args 参数:
String[] arg=new String[3];
arg[0]="--serenity.timeout=1000";
arg[1]="--secretVariable=24C20-00034D2";
arg[2]="--serenity.verbose.steps=FALSE";
这是我能想到的方法。 我没有尝试使用maven来管理这些参数配置,但是我已经使用maven来管理参数模块。 可以用这个方法来管理,而且它支持.yml和.proerties,我举个例子,但是具体的使用方法需要go到springboot官方文档中找到详细的使用方法:
maven:
<!--Configure maven multi-environment development-->
<profiles>
<profile>
<id>enc_dev</id>
<properties>
<profile.active>dev</profile.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>enc_dev</id>
<properties>
<profile.active>dev</profile.active>
</properties>
</profile>
</profiles>
应用程序属性:
spring.profiles.active=@profile.active@
spring.profiles.group.dev=devMVC,devDB
spring.profiles.group.pro=proMVC
这样您就可以轻松管理您想要的模块并进行有针对性的配置,希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.