Jenkins參數化構建 - Maven Command Line傳遞TestNG的參數
阿新 • • 發佈:2018-01-09
main version 使用 blog and htm examples cte ces
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
Jenkins參數化構建 - Maven Command Line傳遞TestNG的參數