简体   繁体   English

从Java中的属性文件读取与从Jenkins Env vars中读取

[英]Read from property file in java vs read from Jenkins Env vars

I'm running automated tests with WebDriver/Junit and the TestData is injected to Jenikins env to be used in the tests. 我正在使用WebDriver / Junit运行自动化测试,并将TestData 注入到Jenikins env中以在测试中使用。 The problem with this is every time we need to run the test locally we need to comment the lines where the Jenkins env var are read and replace them with the correct values. 这样做的问题是,每次我们需要在本地运行测试时,我们都需要注释读取Jenkins env var的行,并用正确的值替换它们。

//private final static String DEFAULT_FILTER=System.getenv("DEFAULT_FILTER"); //私有最终静态字符串DEFAULT_FILTER = System.getenv(“ DEFAULT_FILTER”);
private final static String DEFAULT_FILTER="filter"; 私有最终静态字符串DEFAULT_FILTER =“ filter”;

I think we can move to read the TestData from property file, I know the cost will be bigger, but I'm not sure about how expensive it can be. 我认为我们可以从属性文件中读取TestData,我知道这样做的成本会更高,但是我不确定它的价格会是多少。 Is there a way to reduce the cost reading a property file? 有没有一种方法可以减少读取属性文件的成本? or it's better to continue injecting vars? 还是继续注入vars更好?

How about using the conditional variables in the property file to distinguish either local or in Jenkins. 如何在属性文件中使用条件变量来区分本地变量还是Jenkins变量。 As Peter said, you can also use different profiles with different sets of parameters. 正如Peter所说,您还可以将不同的配置文件与不同的参数集一起使用。

Still, I think conditional variable would be better. 不过,我认为条件变量会更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM