首页 > 其他 > 详细

Jenkins参数化构建 - Maven Command Line传递TestNG的参数

时间:2018-01-09 12:45:38      阅读:484      评论:0      收藏:0      [点我收藏+]

 

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插件中配置

  1. 指定运行的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的参数

原文:https://www.cnblogs.com/xiaochengzi/p/8250852.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!