【发布时间】:2023-04-05 10:45:01
【问题描述】:
我正在使用 eclipse 和 maven 在移动网页上进行移动自动化测试。
我在 pom.xml 中定义以下内容
<properties>
<MY_VARIABLE>www.google.com/</MY_VARIABLE>
</properties>
但是当我调用它时使用
String testurl1 = System.getProperty("MY_VARIABLE");
它似乎总是返回 null。
我也尝试了以下定义变量的方式
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<systemPropertyVariables>
<MY_VARIABLE>www.google.com</MY_VARIABLE>
</systemPropertyVariables>
</configuration>
</plugin>
但仍将值设为 null。
我需要一些帮助 谢谢。
【问题讨论】:
-
您应该为此使用属性文件
-
我认为变量名是混用的。您使用我们的属性 MY_VARIABLE 但在surefire插件配置它的MY_URL / MY_VARIABLE?你使用surefire插件的方式应该可以工作,你可能只是使用了错误的名字?
-
@wemu 我没有在我的代码中使用 MY_VARIABLE 两次,无论是第一种方法还是第二种方法...
-
@RC。你能再解释一下吗..
-
只是您拥有的 xml 无效:
www.google.com