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

问题描述 投票:0回答:1

我的T​​estng Runner

@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>

我的命令:

mvn clean verify -Dexeenv=dev

我的输出:

Testng Value before class=> QA
Testng value at run=> QA

我在maven命令中将exeenv值作为dev传递,但是我始终在输出中仅看到QA。有人可以帮忙吗

java maven testng
1个回答
0
投票

来自文档:

主要有两种方法可以为测试测试提供参数值。

通过testng.xml XML配置文件和通过数据提供程序

[您可能想尝试System.getProperty从命令行读取环境

© www.soinside.com 2019 - 2024. All rights reserved.