Java 无法将参数从maven命令传递到Testng Runner
我的Testng跑步者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
@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