Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.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 无法将参数从maven命令传递到Testng Runner_Java_Maven_Testng - Fatal编程技术网

Java 无法将参数从maven命令传递到Testng Runner

Java 无法将参数从maven命令传递到Testng Runner,java,maven,testng,Java,Maven,Testng,我的Testng跑步者 @Parameters("exeenv") @BeforeClass public void beforeClass(ITestContext context, String exeenv) { System.out.println("Testng Value before class=> " + exeenv); } @Parameters({ "exeenv" }) @Test public void run(String exeenv) { Sys

我的Testng跑步者

@Parameters("exeenv")
@BeforeClass
public void beforeClass(ITestContext context, String exeenv) {

 System.out.println("Testng Value before class=> " + exeenv);
}


@Parameters({
 "exeenv"
})
@Test
public void run(String exeenv) {
 System.out.println("Testng value at run " + exeenv);
 super.run();
}   
我的POM:

<build>
   <plugins>
   <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-failsafe-plugin</artifactId>
      <version>2.19.1</version>
      <configuration>
         <parallel>classes</parallel>
         <threadCount>3</threadCount>
         <testFailureIgnore>true</testFailureIgnore>
         <systemPropertyVariables>
            <testconfig>${testconfig}</testconfig>
            <exeenv>${exeenv}</exeenv>
            <browser>${browser}</browser>
            <uitest>${uitest}</uitest>
         </systemPropertyVariables>
         <suiteXmlFiles>
            <suiteXmlFile>testng.xml</suiteXmlFile>
         </suiteXmlFiles>
         <!-- <includes>
            <include>**/ExecutionRunner.java</include>
            </includes> -->
      </configuration>
      <executions>
         <execution>
            <goals>
               <goal>integration-test</goal>
               <goal>verify</goal>
            </goals>
         </execution>
      </executions>
   </plugin>
</build>
我在maven命令中将exeev值作为dev传递,但我总是在输出中只看到QA。有人能从医生那里帮忙吗

我们可以通过两种方式向testng测试提供参数值

通过testng.xml配置文件和 通过数据提供者


您可能想尝试从命令行读取envs
System.getProperty

谢谢,我使用System.getProperty从命令行读取,如果没有传递任何值,那么我会将变量用于Testng文件。
Testng Value before class=> QA
Testng value at run=> QA