1. Maven使用 -D参数名称 将参数传递至所运行项目
Maven指定TestNg.xml文件
clean test -DsuiteXmlFile=src/main/resources/testng.xml
Maven指定TestNg的groups
clean test -Dgroups=group1,group2
Maven支持的其他运行参数
2.pom.xml指定运行参数,Maven的Surefire Plugin插件中配置
- 指定运行的TestNg.xml文件,suitXmlFile标签中的路径依据实际路径填写
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/main/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
2. 指定TestNg运行的groups
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<groups>functest,perftest</groups>
</configuration>
</plugin>
3.传递运行参数
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<systemPropertyVariables>
<propertyName>firefox</propertyName>
</systemPropertyVariables>
</configuration>
</plugin>
官方文档:http://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html