Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法访问在pom.xml中为maven failsafe插件设置的系统属性_Java_Maven_Autotest_System Properties_Maven Failsafe Plugin - Fatal编程技术网

Java 无法访问在pom.xml中为maven failsafe插件设置的系统属性

Java 无法访问在pom.xml中为maven failsafe插件设置的系统属性,java,maven,autotest,system-properties,maven-failsafe-plugin,Java,Maven,Autotest,System Properties,Maven Failsafe Plugin,我正在使用maven failsafe插件来运行我的自动测试。我在pom.xml中添加了系统属性,需要在代码中使用它们。但是当试图引用它们时,我总是得到“null”而不是属性值。我已经看了常见问题,并试图以不同的方式玩它,但仍然没有成功 下面是我的pom.xml的一个片段,其中包含提到的插件: <plugin> <groupId>org.apache.maven.plugins</groupId> <art

我正在使用maven failsafe插件来运行我的自动测试。我在pom.xml中添加了系统属性,需要在代码中使用它们。但是当试图引用它们时,我总是得到“null”而不是属性值。我已经看了常见问题,并试图以不同的方式玩它,但仍然没有成功

下面是我的pom.xml的一个片段,其中包含提到的插件:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.19.1</version>
            <configuration>
               <parallel>methods</parallel>
               <threadCount>${threads}</threadCount>
               <systemPropertyVariables>
               <browser>MYSYSTEMPROPERTY</browser>
                  <!--Set properties passed in by the driverbinary downloader-->
                  <webdriver.chrome.driver>${webdriver.chrome.driver}</webdriver.chrome.driver>
                  <webdriver.ie.driver>${webdriver.ie.driver}</webdriver.ie.driver>
                  <webdriver.opera.driver>${webdriver.opera.driver}</webdriver.opera.driver>
               </systemPropertyVariables>
               <includes>
                  <include>**/*WD.java</include>
               </includes>
            </configuration>
            <executions>
               <execution>
                  <goals>
                     <goal>integration-test</goal>
                     <goal>verify</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>

org.apache.maven.plugins
maven故障保护插件
2.19.1
方法
${threads}
MYSYSTEMPROPERTY
${webdriver.chrome.driver}
${webdriver.ie.driver}
${webdriver.opera.driver}
**/*WD.java
集成测试
验证
也就是说,我对获取属性浏览器属性值感兴趣(它应该返回'MYSYSTEMPROPERTY')。下面是我在代码中引用它的方式:


System.getProperty(“browser.toUpperCase())

为什么要执行
System.getProperty(“browser.toUpperCase())
。属性名称区分大小写。使用
System.getProperty(“浏览器”)
Deendayal Garg,非常感谢,这就解决了问题。我的错…它应该是(System.getProperty(“browser”).toUpperCase());它起作用了。再次感谢!很高兴我能帮忙。快乐的编码。你为什么要做
System.getProperty(“browser.toUpperCase())
。属性名称区分大小写。使用
System.getProperty(“浏览器”)
Deendayal Garg,非常感谢,这就解决了问题。我的错…它应该是(System.getProperty(“browser”).toUpperCase());它起作用了。再次感谢!很高兴我能帮忙。快乐编码。